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
https://forums.phpfreaks.com/topic/105364-updating-records/
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
https://forums.phpfreaks.com/topic/105364-updating-records/#findComment-539636
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.