0

Good morning all,

I am having a few issues. Firstly, I am no expert whatsoever so I may not have done anything conventionally. I have been able to create a form with many fields, click submit and data is inserted into a table in my database. I was then also able to create a page that displays all of the fields and rows from my database.

Next step I did was create a link next to each row, to "Update" that row's information. The way the Update link is currently set up is to take the 'FOB PO #" from that row and redirect to an update page, (update2.php?id=54321). Then grab the id from the link and have it access the right id in my database.

I am having issues with creating a page that will show the information from the correct row, in an html text fields, so they can be edited by a user, then submitted again and update the correct field, without creating a new entry into the database.

I am currently getting an error "Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/fobintl/public_html/tracking/admin/update2.php on line 23"

The following, is the update page in its current form:

$id = $_GET['id'];

$query=" SELECT * FROM data WHERE id='fob_po'";
$result=mysql_query($query);
$num=mysql_num_rows($result);        
mysql_close();

$i=0;
while ($i < $num) {
$cust_po=mysql_result($result,$i,"cust_po");
$cust_po_date=mysql_result($result,$i,"cust_po_date");
$fob_po=mysql_result($result,$i,"fob_po");
$fob_po_date=mysql_result($result,$i,"fob_po_date");
$style_num_approved=mysql_result($result,$i,"style_num_approved");
$style_num_date=mysql_result($result,$i,"style_num_date");
$tops_date=mysql_result($result,$i,"tops_date");
$est_depart=mysql_result($result,$i,"est_depart");
$est_arrive=mysql_result($result,$i,"est_arrive");
$ship_mode=mysql_result($result,$i,"ship_mode");
$track_num=mysql_result($result,$i,"track_num");
$fob_comments=mysql_result($result,$i,"fob_comments");
?>

<form action="process-update.php" method="post">
<input type="hidden" name="ud_id" value="<?php echo $id; ?>">
Customer PO #: <input type="text" name="ud_first" value="<?php echo $cust_po; ?>"><br>
Date PO # Recieved: <input type="text" name="ud_last" value="<?php echo $cust_po_date; ?>"><br>
FOB PO #: <input type="text" name="ud_phone" value="<?php echo $fob_po; ?>"><br>
FOB PO # Date: <input type="text" name="ud_mobile" value="<?php echo $fob_po_date; ?>"><br>
Style # Approved: <input type="text" name="ud_fax" value="<?php echo $style_num_approved; ?>"><br>
Date Approved: <input type="text" name="ud_email" value="<?php echo $style_num_date; ?>"><br>
TOPS Date Sent: <input type="text" name="ud_web" value="<?php echo $tops_date; ?>"><br>
ETD: <input type="text" name="ud_web" value="<?php echo $est_depart; ?>"><br>
ETA: <input type="text" name="ud_web" value="<?php echo $est_arrive; ?>"><br>
Shipping Mode: <input type="text" name="ud_web" value="<?php echo $ship_mode; ?>"><br>
Tracking Number: <input type="text" name="ud_web" value="<?php echo $track_num; ?>"><br>
Comments: <input type="text" name="ud_web" value="<?php echo $fob_comments; ?>"><br>
<input type="Submit" value="Update">
</form>
<?php
++$i;
}
?>
1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by kbailey1734
0

Okay, so I no longer am getting the error in regards to "Warning: mysql_num_rows(): supplied...etc etc".

I messed up

$id = $_GET['id'];

$query=" SELECT * FROM data WHERE fob_po='id'";
$result=mysql_query($query);
$num=mysql_num_rows($result);        
mysql_close();

But now my problem is that nothing on the page shows up...no text or text box's for input or anything.

Here is what the code looks like now except im not posting the db connection with name, password etc:

mysql_select_db("fobintl_tracking", $con);

$id = $_GET['id'];

$query=" SELECT * FROM data WHERE fob_po='id'";
$result=mysql_query($query);
$num=mysql_num_rows($result);        
mysql_close();

$i=0;
while ($i < $num) {
$cust_po=mysql_result($result,$i,"cust_po");
$cust_po_date=mysql_result($result,$i,"cust_po_date");
$fob_po=mysql_result($result,$i,"fob_po");
$fob_po_date=mysql_result($result,$i,"fob_po_date");
$style_num_approved=mysql_result($result,$i,"style_num_approved");
$style_num_date=mysql_result($result,$i,"style_num_date");
$tops_date=mysql_result($result,$i,"tops_date");
$est_depart=mysql_result($result,$i,"est_depart");
$est_arrive=mysql_result($result,$i,"est_arrive");
$ship_mode=mysql_result($result,$i,"ship_mode");
$track_num=mysql_result($result,$i,"track_num");
$fob_comments=mysql_result($result,$i,"fob_comments");
?>

<form action="process-update.php" method="post">
<input type="hidden" name="ud_id" value="<?php echo $id; ?>">
Customer PO #: <input type="text" name="ud_first" value="<?php echo $cust_po; ?>"><br>
Date PO # Recieved: <input type="text" name="ud_last" value="<?php echo $cust_po_date; ?>"><br>
FOB PO #: <input type="text" name="ud_phone" value="<?php echo $fob_po; ?>"><br>
FOB PO # Date: <input type="text" name="ud_mobile" value="<?php echo $fob_po_date; ?>"><br>
Style # Approved: <input type="text" name="ud_fax" value="<?php echo $style_num_approved; ?>"><br>
Date Approved: <input type="text" name="ud_email" value="<?php echo $style_num_date; ?>"><br>
TOPS Date Sent: <input type="text" name="ud_web" value="<?php echo $tops_date; ?>"><br>
ETD: <input type="text" name="ud_web" value="<?php echo $est_depart; ?>"><br>
ETA: <input type="text" name="ud_web" value="<?php echo $est_arrive; ?>"><br>
Shipping Mode: <input type="text" name="ud_web" value="<?php echo $ship_mode; ?>"><br>
Tracking Number: <input type="text" name="ud_web" value="<?php echo $track_num; ?>"><br>
Comments: <input type="text" name="ud_web" value="<?php echo $fob_comments; ?>"><br>
<input type="Submit" value="Update">
</form>
<?php
++$i;
}
?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.