I have a couple of scripts. One inserts data into a MySql DB, a second displays the results if success. This workks well inserting data. The third script of which I have copied a snippet of code has two small bugs. One, it does not grab the "description" and places it in a text area. The second, does not select the proper option on the dropdown list. Any ideas? The remains code works. If you need more info please let me know or if you need a copy of the entire page.
Thanks in advance!!!
-Don
...MORE CODE ABOVE
$query = "SELECT * FROM remains WHERE " .
"item_no = $item_no";
// Connect to the MySQL DBMS
if (!($connection = @ mysql_connect($hostName,
$username,
$password)))
die("Could not connect to database");
if (!mysql_select_db($databaseName, $connection))
showerror();
// Run the query on the DBMS
if (!($result = @ mysql_query ($query, $connection)))
showerror();
//$row = mysql_fetch_array($result);
// Reset $formVars, since we're loading from
// the customer table
$formVars = array();
if ($row = @ mysql_fetch_array($result))
{//start of this IF
$formVars["item_no"] = $item_no;
$formVars["title"] = StripSlashes($row["title"]);
$formVars["description"] = StripSlashes($row["description"]);
$formVars["price"] = $row["price"];
$formVars["ship"] = $row["ship"];
//$formVars["image_[1]"] = $row["image_[1]"];
//$formVars["image_[2]"] = $row["image_[2]"];
//$formVars["image_[3]"] = $row["image_[3]"];
//$formVars["image_[4]"] = $row["image_[4]"];
$formVars["category "] = $row["category"];
$formVars["legacy_id"] = $row["legacy_id"];
$formVars["visible"] = $row["visible"];
$formVars["security"] = $row["security"];
$formVars["count"] = $row["count"];
$formVars["quantity"] = $row["quantity"];
}//end of this IF
?>
<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Remains To Be Seen Website Manager - Update An Existing Item</title>
</head>
<body>
<h2><font color="red">Remains To Be Seen Website Manager</font color></h2>
<h2><font color="red">Update An Existing Item</font color></h2>
<form enctype="multipart/form-data"
action="update1.php" method="post">
Item No (only for updates, leave blank for new items)
<br><input type="text" name="item_no" value="<?php echo $formVars["item_no"]; ?>" size=10><br><br>
Title
<br><input type="text" name="title" value="<?php echo $formVars["title"]; ?>" size=80><br>
<br>Description:
<br><textarea name="description" rows=10 cols=80 value="<?php echo $formVars["description"]; ?>">
</textarea><br>
<table border="0">
<tr><TD WIDTH="150">Price</td><TD WIDTH="150">Shipping</td><TD WIDTH="150">Legacy Item No.</td></tr>
<tr><td><input type="text" name="price" value="<?php echo $formVars["price"]; ?>" size=10></td>
<td><input type="text" name="ship" value="<?php echo $formVars["ship"]; ?>" size=10></td>
<td>
<input type="text" name="legacy_id" value="<?php echo $formVars["legacy_id"]; ?>" size=10></td></tr>
<tr><TD WIDTH="150">Visible?</td><TD WIDTH="150">Security Field</td><TD WIDTH="150">Quantity</td></tr>
<tr><td>
<input type="text" name="visible" value="<?php echo $formVars["visible"]; ?>" size=10></td>
<td>
<input type="text" name="security" value="<?php echo $formVars["security"]; ?>" size=10></td>
<td>
<input type="text" name="quantity" value="<?php echo $formVars["quantity"]; ?>" size=10></td>
</tr>
<tr><td>Count</td><td> </td><td> </td></tr>
<tr><td><input type="text" name="count" value="<?php echo $formVars["count"]; ?>" size=10></td><td> </td><td> </td></tr>
</table>
<br>Category:
<br>
<select name="category" selected="<?php echo $formVars["category"]; ?>">
<option value="">Select an Option</option>
<option value="">-- PHOTOGRAPHS--</option>
<option value="dag">Daguerreotype</option>
<option value="amb">Ambrotype</option>
<option value="tin">Tintype</option>
<option value="cab">Cabinet Card</option>
<option value="cdv">CDV</option>
<option value="alb">Albumen</option>
<option value="tpc">Thermoplatic Cases</option>
<option value="20t">20th Century</option>
<option value="">-- DECORATIVES--</option>
<option value="luc">Lucite Purse</option>
<option value="vin">Vintage Purse</option>
<option value="dec">Decoratives</option>
</select> <br><br>
<input type="hidden" name="MAX_FILE_SIZE" value="5000000">
<input type="hidden" name="MAX_EXECUTION_TIME" value="600">
<br>
<font color ="red"><b>PLEASE LEAVE IMAGE FIELDS BLANK UNLESS YOU INTEND TO UPDATE CURRENT IMAGES BELOW.</br></font color>
<br>Image 1 (Thumbnail of this image will be created):
<input name="image_[]" type="file"><br>
<br>Image 2 (Optional, leave blank if no image):
<input name="image_[]" type="file"><br>
<br>Image 3 (Optional, leave blank if no image):
<input name="image_[]" type="file"><br>
<br><input type="submit">
</form>
<?php
echo "\n<br><br>Image: </B>" . $row["image_1"];
?><br><br><img src="http://127.0.0.1/remains_final/photos/<?php echo $row['image_1']; ?>"><br><br><?php
if ($row["image_2"] <> 'NULL')
{
echo "\n<br><br>Image: </B>" . $row["image_2"];
?><br><br><img src="http://127.0.0.1/remains_final/photos/<?php echo $row['image_2']; ?>"><br><br><?php
}
if ($row["image_3"] <> 'NULL')
{
echo "\n<br><br>Image: </B>" . $row["image_3"];
?><br><br><img src="http://127.0.0.1/remains_final/photos/<?php echo $row['image_3']; ?>"><br><br><?php
}
if ($row["image_4"] <> 'NULL')
{
echo "\n<br><br>Image: </B>" . $row["image_4"];
?><br><br><img src="http://127.0.0.1/remains_final/thumbs/<?php echo $row['image_4']; ?>"><br><br><?php
}
?>
<br><br><a href="../remains_final/">Main Page</a><br>
<br><br><a href="../remains_final/udpate1.php">Insert Page</a><br>
</body>
</html>
<?php
}
else... More code follows...