Can't update MySQL correctly
Posted: Mon Apr 03, 2006 12:29 pm
Ok, here's my problem.
I want the visitor to be able to update the kind of paper, and how many in quantity of a photo. But sometimes it'll do it, sometimes it'll get ignored. I do want it to ignore the mysql_query but only when 3 cols are the same. Here's my code:
Here's the results as an image.

Order goes like so:
itemid
itemname
size
paper
quantity
subtotal
And my database table:

As always, help would greatly be appreciated.
I want the visitor to be able to update the kind of paper, and how many in quantity of a photo. But sometimes it'll do it, sometimes it'll get ignored. I do want it to ignore the mysql_query but only when 3 cols are the same. Here's my code:
Code: Select all
<?php require_once('../Connections/prophot.php'); ?>
<?php
for($u = 0; $u < count($size); $u++)
{
print "$itemid[$u]<br>";
print "$filename[$u]<br>";
print "$size[$u]<br>";
print "$paper[$u]<br>";
print "$quantity[$u]<br>";
mysql_select_db($database_prophot, $prophot);
$query_callprices = 'SELECT * FROM prices WHERE size = "'. $size[$u] .'" AND paper = "' .$paper[$u] .'"';
$callprices = mysql_query($query_callprices, $prophot) or die(mysql_error());
$row_callprices = mysql_fetch_assoc($callprices);
$totalRows_callprices = mysql_num_rows($callprices);
$subtotal = $row_callprices['price'];
$subtotal = $subtotal * $quantity[$u];
echo "Subtotal $subtotal";
print "<hr width=\"125\" align=\"left\">";
$sql = 'SELECT * FROM items WHERE itemname= "'. $filename[$u] .'" AND size = "'. $size[$u] .'" AND paper = "'. $paper[$u] .'"';
$query = mysql_query($sql) or die(mysql_error());
$row_sql = mysql_fetch_assoc($query);
$totalRows_sql = mysql_num_rows($query);
if(mysql_num_rows($query) != 0){
//ignore only when the itenmane, size, and paper is the same...
}else{
//...otherwise update it.
mysql_query('UPDATE items SET paper="'. $paper[$u] .'", quantity="'. $quantity[$u] .'", subtotal="'. $subtotal .'" WHERE itemid="'. $itemid[$u] .'"');
}
}
?>
Order goes like so:
itemid
itemname
size
paper
quantity
subtotal
And my database table:

As always, help would greatly be appreciated.