Jump to content

trying to update some coluns with PHP-MySQL


zpupster

Recommended Posts

Hello PHP Freaks,

 

First Post:

 

I am writing a page  to UPDATE   some table fields.

 

this works OK!

//Select Query
$result = mysql_query( "SELECT products.products_id AS id, products_description.products_name AS name,
 products.products_quantity AS quantity, products.products_weight AS weight, products.products_price AS price
 FROM products, products_description WHERE products.products_id=products_description.products_id;") or die(mysql_error());
//$sql = SELECT  products.products_id, products_description.products_name,  products.products_price, //products.products_quantity, products.products_weight`
//FROM 
//`products`
//JOIN `products_description WHERE products.products_id = products_description.products_id






echo "<table width='90%'>";
echo "<tr>";
echo "<th width='8%'>Id</th>";
echo "<th width='30%'>Name</th>";
echo "<th width='15%'>Quantity</th>";
echo "<th width='15%'>Weight</th>";
echo "<th width='15%'>Price</th>";
echo "<th width='7%'>Update</th></tr></table>";




    while($row = mysql_fetch_array ($result))
{
echo "<table width='90%'>";
echo "<tr><form action = update.php method = post><td width='8%'>";
echo $row['id'];
echo "</td><td width='50%'>";
echo $row['name'];
echo "</td><td width='5%'><input type=text name=quantity value='".$row['quantity']."'></td>";
echo "<td width='10%'><input type=text name=weight value='".$row['weight']."'></td>";
echo "<td width='10%'><input type=text name=price value='".$row['price']."'></td>";
echo "<td width='7%'><input type=submit value='Update'></td>";
echo "</form></tr></table>";
}




?>

This is giving Error-Not Updated

 

//Update Query


$result = "UPDATE products 
INNER JOIN products_description ON (products.products_id = products_description.products_id) 
SET id ='.$id.',
name ='.$name.,' ,
quantity = '$_POST[quantity]', 
weight = '$_POST[weight]', 
price= '$_POST[price]', 


WHERE 'products.products_id' = 'products_description.products_id'";


//Execute Query
if (mysql_query($result))
header("Location: davesConnectDB.php");
else
echo  "Not Updated!";


 ?>

 It was updating but in the wrong record,  I have been working on this for a long time.

 

Help is greatly appreciated.

 

TY,

Zpupster

 

Link to comment
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.