Ok i have a dreamweaver
php file called "Display pic.
php" and i have succesfully dragged records to display from a mysql database into text boxes on the
php file, one of the text boxes is recording the name of the image from the database, i uploaded the image into the images2 folder located in my sites directory to save clogging up teh database. So the image is located in the images2 file & the name of the image goes into the databases with the rest of the records. I need to display the image in the table at the bottom of my
php file.
So basically i have records from my mysql database displaying in text fields on my
php file, and i would like a code example of how to get the image to display in the table under the text boxes, aswell as just the name of the image.
Below is my database "dblearn", and the code is using the table called employees:
CREATE DATABASE IF NOT EXISTS dblearn;
USE dblearn;
CREATE TABLE employees (name VARCHAR(30), email VARCHAR(30), phone VARCHAR(30), photo VARCHAR(30))
Here is my code:
- PHP: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$con = mysql_connect("localhost","root","longstand")
or
die('Damn!, the crazy guinea pigs must have started nibbling on my computer cords again. MYSQL reckons <pre>' . mysql_error() . '</pre>');
mysql_select_db("dblearn", $con)
or
die ('Feckin hell, if it\'s not the guinea pigs then it\'s the gerbils. I shouldn\'t let rodents near the computer. MYSQL reckons <pre>' . mysql_error() . '</pre>');
$name = 'Mr Andrew Lloyd';
$query = "SELECT * FROM employees WHERE name = '$name' LIMIT 1";
$result = mysql_query($query)
or
die ('I finally got rid of the rodents now the grasshoppers are having a dig. damn. MYSQL reckons <pre>' . mysql_error() . '</pre>');
if (!mysql_num_rows($result))
die ('Did you lie to me? You said that was your name but nothing matched it in the result. I feel so dirty');
$details = mysql_fetch_array($result);
mysql_free_result($result);
mysql_close($con);
?>
<p>My Name Is</p>
<p>
<label>
<input type="text" name="name" id="name"value="<?php echo isset($details['name']) ? $details['name'] : ''; ?>" />
</label>
</p>
<p>My Email Address Is</p>
<p>
<label>
<input type="text" name="email" id="email"value="<?php echo isset($details['email']) ? $details['email'] : ''; ?>" /><br />
</label>
</p>
<p>
<label></label>
My Phone Number Is</p>
<p>
<label>
<input type="text" name="phone" id="phone"value="<?php echo isset($details['phone']) ? $details['phone'] : ''; ?>" /><br />
</label>
</p>
<p>My Photo's Called</p>
<p>
<label>
<input type="text" name="photo" id="photo" value="<?php echo isset($details['photo']) ? $details['photo'] : ''; ?>" /><br />
</label>
</p>
<table width="200" height="196" border="1">
<tr>
<td> </td>
</tr>
</table>
<p> </p>
<p>
<label></label>
</p>
<p> </p>
<p> </p>
<p> </p>
</body>
</html>
Please help!
Cheers.
