![]() |
Rendering MySQL output to edit in a form
Im coding a form to upload items into MySQL database, everything works fine except when i click "edit" (to change details with that item) the data doesnt render in the form...
<?php // Gather this product's full information for inserting automatically into the edit form below on page if (isset($_GET['pid'])) { $targetID = $_GET['pid']; $sql = mysql_query("SELECT * FROM products WHERE id='$targetID' LIMIT 1"); $productCount = mysql_num_rows($sql); // count the output amount if ($productCount > 0) { while($row = mysql_fetch_array($sql)){ $product_name = $row["product_name"]; $price = $row["price"]; } } else { echo "Item doesnt exist!"; exit(); } } ?> |
Because you are limiting your query to 1 result, you don't actually need a while loop, so remove the while to leave you with this inside the if:
PHP Code:
Also, could you post your form code? |
You're only showing php code there. You're not showing us any code that actually puts the data directly into the form or even tries to do so.
|
| All times are GMT +1. The time now is 01:30 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.