Jump to content

Updating records.


vomitbomb

Recommended Posts

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>

Link to comment
Share on other sites

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'.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.