Jump to content

papaface

Members
  • Posts

    1,437
  • Joined

  • Last visited

    Never

Posts posted by papaface

  1. No, because $key is the value of all the input field names on the previous page. So I would end up getting "name,order1,order2,order3,order4,order5" all put into the order_name field. Whereas I just want the value of the "name" $key added.
  2. [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.
  3. Thanks for that, but it isnt what i really need.
    Im trying to include a specific input field that has been posted to this script in a peice of SQL coding.
    In order to do that i need to do something like $key[name] but that doesnt work.
    Any ideas?
  4. Hello,
    I was wondering if someone can help me.
    I am trying to make a kind of shopping cart.
    A person submits a form of checkboxes with each items quantity equaling "1".
    How would I go about checking in the mysql database if the name of that item exists in the order table, and if so increment the current quantity stored in the table by one.
    On the other hand if the value is not present, add it with the quantity equalling 1.
    Hope you can understand that. I would appreciate any help anyone can give.

    Thanks.

    edit:
    The code I currently have in a script named process.php is:

    [code]if (isset($_POST["submit"]))
    {
    foreach ($_POST as $key => $value)
    {
    if ($key != "submit")
    {
    mysql_query("insert into orders (order_item) values ('$value')",$con) or die (mysql_error());
    }

    }

    }[/code]
  5. Hello,
    I was wondering if someone can help me.
    Currently I have the following code in a file named submit.php:
    [code]<?php

    require("includes/connect.php");
    require("includes/selectdb.php");
    ?>
    <form action="process.php" method="post">
    <?php
    $sql = mysql_query("select id,name from groceries",$con);
    while (list($id,$name) = mysql_fetch_array($sql))
    {?>
    <label><?=$name?><input name="<?=$id?>" type="checkbox" value="<?=$name?>"></label><br>
    <?php }
    ?>
    </form>[/code]

    How would I go about adding the values of an unlimited amount of checkboxes to a database?
  6. Its good for that website. But as I mentioned the link I gave you isnt the link I want to use. The link I want to use is for something completely different. I basically need the ability to enter a phrase and for php to bring back the phrase then the number to the right of it, whether it be a currency or just a number. Do you have any other method of contact besides the forum The Little Guy ?
  7. [code]<?php

    $file = file_get_contents("http://www.amazon.co.uk/Sony-Ericsson-W800i-Vodafone-Weekends/dp/B000BSRU6I")or die ("error " . mysql_error());
    echo $file;
    preg_match_all("~^Price: \£[0-9]$/i~", $file,$out, PREG_PATTERN_ORDER);
    foreach($out[0] as $value){
        echo $value.'<br>';
    }
    ?>
    [/code]
    That is what im using. Its not the URL im really trying to use, but it still doesnt work.
×
×
  • 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.