Forum Moderators: coopster

Message Too Old, No Replies

Update from form

retrieving data to a form so it can be edited easily

         

YnotInTX

11:52 pm on Mar 28, 2005 (gmt 0)

10+ Year Member



The file below is supposed to bring up a form with the fields for a user inserted into it for editing. "edit.php?id=83" is an example of the link to it. When that link is clicked the page is empty and the is no code in the source view.

<?
include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="select from todo where id='".$_GET['id']."' LIMIT 1";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();

$i=0;
while ($i < $num) {
$item=mysql_result($result,$i,"item");
$description=mysql_result($result,$i,"description");
$category=mysql_result($result,$i,"category");
$priority=mysql_result($result,$i,"priority");

?>

<form action="updated.php">
<input type="hidden" name="ud_id" value="<? echo "$id";?>">
Item: <input type="text" name="ud_item" value="<? echo "$item"?>"><br>
Description: <input type="text" name="ud_description" value="<? echo "$description"?>"><br>
Category: <input type="text" name="ud_category" value="<? echo "$category"?>"><br>
Priority: <input type="text" name="ud_priority" value="<? echo "$priority"?>"><br>
<input type="Submit" value="Update">
</form>

<?
++$i;
}
?>

jatar_k

12:06 am on Mar 29, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



then my wild guess is that $num == 0

so I would imagine your query is dying or not returning any rows.

1. try echoing the query to make sure it is getting the id properly
2. try executing the query itself via the commandline or in phpmyadmin
3. add an - or die (mysql_error()) to your mysql_query call to see if there is an error of some kind returned from mysql
4. echo out $num before you go into your while statement to see if it is infact 0
5. echo $i in each iteration of your while loop to see how many times it is looping in relationship to the value of $num

that should help you isolate why