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