vomitbomb Posted May 13, 2008 Share Posted May 13, 2008 I have a page that is showing the orders from the database, a search string is sent to this by a form on another page and the order pops up. At the bottom I want to have a button to close the order, so I want to use UPDATE to change the orders status. How can I take the value of $row FROM this script and on the click of a button, put it in another script where it'll be updated? <? //make the database connection $conn = mysql_connect("localhost", "", ""); mysql_select_db("example, $conn); $search = $_POST['search']; //create a query $sql = "SELECT * FROM orders WHERE lname='$search'"; $result = mysql_query($sql, $conn); $row = mysql_fetch_array( $result ); if (!$row) { echo "<table border=0 align=center>"; echo "<tr><td>"; echo '<b>Search returned no results!</b><meta http-equiv="refresh" content="3;url=order.html">'; echo "</tr></td>"; echo "</table>"; die(''. mysql_error()); } //Creating table echo "<table border=0 align=center colspan=2>"; echo "<tr><td align=center colspan=2 bgcolor=#999999>"; echo "<h3>Showing Order for: </h3>"; echo "</tr></td>"; echo "<tr><td colspan=2 bgcolor=#CCCCCC align=center>"; echo "<b><u>" .$row['fname']; echo " " .$row['lname']; echo "</b></u>"; echo "<br>"; mysql_close($conn); echo "</tr></td>"; ?> </table> Quote Link to comment Share on other sites More sharing options...
vomitbomb Posted May 13, 2008 Author Share Posted May 13, 2008 Ok I put in: <form method="post" action="closeorder.php"> <input name="closeorder" type="hidden" value="<?php print $search; ?>"> <input type="submit" value="Close Order"> </form> At the bottom of the showorders page, then I send it to the closeorder.php page and print the value of $search and it just gives me 'Resource id #3'. Quote Link to comment Share on other sites More sharing options...
haku Posted May 13, 2008 Share Posted May 13, 2008 A Resource id is often (always?) a value that has come directly out of a mysql DB, but has not been converted to a form PHP can use. You need to use mysql_fetch_array or mysql_fetch_row or mysql_result or something in order to be able to utilize the data from the database. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.