Jump to content

Updating MySQL problem


timmah1

Recommended Posts

here is my form

<form name="processed" action"" method="POST">
	<input type="hidden" name="order_number" id="order_number" value="<?php echo $row['order_number']; ?>">
	<input type="hidden" name="update" id="update" value="y">
	<input type="hidden" name="status" id="status" value="y">
	<input type="submit" name="Submit" value="Mark as processed <?php echo $row['id']; ?>">
	</form>

 

Here is the update

if($_POST['update']=="y") {
$result = mysql_query("UPDATE `order` SET processed='".$_POST['status']."' where order_number = '".$_POST['order_number']."'") 
or die(mysql_error());  
echo "Order updated<br>Please wait...<meta http-equiv=\"refresh\" content=\"1; url=?cid=adminStatus\" />";;
}

 

Why won't this update?

 

Thanks in advance

Link to comment
Share on other sites

I put my sql strings into a variable before calling mysql_query. Then when I have problems like this it is easy to look at the query and check it is OK or not. Try

 

if($_POST['update']=="y") {
  $sql = "UPDATE `order` SET processed='".$_POST['status']."' where order_number = '".$_POST['order_number']."'";
  echo '<pre>', $sql, '</pre>';
  $result = mysql_query($sql) 
     or die(mysql_error());  
  echo "Order updated<br>Please wait...<meta http-equiv=\"refresh\" content=\"1; url=?cid=adminStatus\" />";;
}

Link to comment
Share on other sites

It does the exact same thing.

 

Here is my entire code for this page

<?php
include "DB_config.php";
//if($_POST['update']=="y")
//die("=)") {
//$result = mysql_query("UPDATE `order` SET processed='".$_POST['status']."' where order_number = '".$_POST['order_number']."'") 
//or die(mysql_error());  
//echo "Order updated<br>Please wait...<meta http-equiv=\"refresh\" content=\"1; url=?cid=adminStatus\" />";;
//}
if($_POST['update']=="y") {
  $sql = "UPDATE `order` SET processed='".$_POST['status']."' where order_number = '".$_POST['order_number']."'";
  echo '<pre>', $sql, '</pre>';
  $result = mysql_query($sql) 
     or die(mysql_error());  
  echo "Order updated<br>Please wait...<meta http-equiv=\"refresh\" content=\"1; url=?cid=adminStatus\" />";;
}
else {
$user = "SELECT * FROM `order`";
$result = mysql_query($user);

$numberall = mysql_Numrows($result);
?>
<h1>Main System Admin</h1>
<table width="90%" border="0" cellspacing="0" cellpadding="10">
  <tr> 
    <td bgcolor="#801013"><strong><font color="#FFFFFF">All Orders - Status </font></strong></td>
  </tr>

  <tr> 
    <td>

<table width="100%" border="0">
      <tr>

        <td>Name</td>
        <td>Address</td>
        <td>Phone</td>
        <td>Quantity</td>
        <td>Status</td>
        </tr>
	 <?php
if ($numberall==0) {
    echo "<strong>There are no orders</strong>"; 
}
?>
	 <?php
  while($row = mysql_fetch_array( $result )){
  ?>
      <tr valign="top">
    <td><?php echo $row['f_name']; ?> <?php echo $row['l_name']; ?></td>
        <td><?php echo $row['address']; ?><br>
	<?php echo $row['city']; ?>, <?php echo $row['state']; ?><br>
	<?php echo $row['zip']; ?></td>
        <td><?php echo $row['phone']; ?></td>
        <td><?php echo $row['quantity']; ?></td>
        <td><?php
	if($row['status']=="n"){
	?>
	<form name="processed" action"" method="POST">
	<input type="hidden" name="order_number" id="order_number" value="<?php echo $row['order_number']; ?>">
	<input type="hidden" name="update" id="update" value="y">
	<input type="hidden" name="status" id="status" value="y">
	<input type="submit" name="Submit" value="Mark as processed <?php echo $row['id']; ?>">
	</form>
	<?php
	}
	else {
	?>
	<form name="unprocessed" action"" method="POST">
	<input type="hidden" name="order_number" id="order_number" value="<?php echo $row['order_number']; ?>">
	<input type="hidden" name="update" id="update" value="y">
	<input type="hidden" name="status" id="status" value="n">
	<input type="submit" name="Submit" value="Mark as un-processed <?php echo $row['order_number']; ?>">
	</form>
	<?php
	}
	?></td>
        </tr>
	<?php
	}
	?>
    </table></td>
  </tr>

</table>
<?php
	}
	?>

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.