Jump to content

Select a specific key


papaface

Recommended Posts

[code]if (isset($_POST["submit"]))
{
foreach ($_POST as $key => $value)
{
if ($key != empty($value))
{

if ($key != "submit")

{
$query = mysql_query("SELECT * FROM orders WHERE order_item = '$value'");
$check = mysql_num_rows($query);
if(!$check)
{
  mysql_query("insert into orders (order_item) values ('$value')",$con);
 
}
else {
$query = mysql_query("SELECT order_quantity FROM orders WHERE order_item='$value'");
$data = mysql_fetch_assoc($query);
$quantity = $data["order_quantity"];
$quantity = $quantity + 1;
  mysql_query("UPDATE orders SET order_quantity=$quantity WHERE order_item='$value'");
}
}
}

}
echo "Thank your for your order!";

}[/code]

^^ that is what I have at the moment. Presently that code will input into the database the values into the order_items table. I want all the $values to go into the items field, except for the name field (that was submitted on a previous page). I want the name value to be inserted into the same row as the order_items. Very difficult to explain, but I want to achieve this:
[code]mysql_query("insert into orders (order_item,order_name) values ('$value','THEVALUEOFTHENAMEFIELDONPREVIOUSPAGESHOULDBEINSERTEDHERE')",$con);[/code]

hope that clears things up a little.
Link to comment
https://forums.phpfreaks.com/topic/30806-select-a-specific-key/#findComment-142042
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.