Jump to content

156418

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Everything posted by 156418

  1. Thanks, populating the menu as expected. 8)
  2. This is probably a simple request, but I cant seem to find an answer - all I can find are answers that are doing more sophisticated things. I'm running this query: [code]<?php //we need to connect to the database so require('db/db_connect.php'); ?> <?php $query = "SELECT * FROM EventDates WHERE EventID = '22'"; $results = mysql_query($query) or die(mysql_error()); ?>[/code] Which works no problem, as I can get the results to display as Text. However I'd like to take the results and put them into a Drop Down Menu to pass on to the next part of my form. Could anyone adivse how I take the results and put the into the drop down, I cant seem to get the code right, and just get the php partly displayed in the box!
  3. The post array is there to pass the data onto a payment system (such as World Pay etc) but all I'm doing is passing it onto a new page, all of the items post correctly apart from orderid and product_name fields. i.e all what I'm doing at the bottom is summing it up ready to pass on. However on that page it shows the user their "order" and the orderid and product_name work ok  until it gets to the bottom form ready to be passed onto the next stage ??? I've taken a screenshot of the results that it produces, you'll see that it has an order number and the product name is listed in the top half, but the form at the bottom, which is collecting the data ready to pass on it isnt showing, where as everything else is working: [img]http://img178.imageshack.us/img178/2726/outputfs9.gif[/img]
  4. Hi, I'm playing around with a shopping script, but cannot seem to get two echo functions to work. I have a form with 13 fields, 11 of them pick up the data from the database ok, but orderid and products_purchased dont work. (Script is below) [code]<?php session_start(); $connect = mysql_connect ("localhost", "mysqlusername", "mysqlpassword") or die ("Connection to Database Failed."); mysql_select_db("testdb"); //Let's make the variables easy to access in our queries $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $firstname = $_POST['firstname']; $add1 = $_POST['add1']; $add2 = $_POST['add2']; $city = $_POST['city']; $county = $_POST['county']; $postcode = $_POST['postcode']; $phone = $_POST['phone']; $fax = $_POST['fax']; $email = $_POST['email']; $total = $_POST['total']; $sessid = session_id(); $today = date("Y-m-d"); //1) Assign Customer Number to new Customer, or find existing customer number $query = "SELECT * FROM customers WHERE           (customers_firstname = '$firstname' AND           customers_lastname = '$lastname' AND           customers_add1 = '$add1' AND           customers_add2 = '$add2' AND           customers_city = '$city')"; $results = mysql_query($query)   or (mysql_error()); $rows = mysql_num_rows($results); if ($rows < 1) {   //assign new custnum   $query2 = "INSERT INTO customers (             customers_firstname, customers_lastname, customers_add1,             customers_add2, customers_city, customers_county,             customers_postcode, customers_phone, customers_fax,             customers_email)             VALUES (             '$firstname',             '$lastname',             '$add1',             '$add2',             '$city',             '$county',             '$postcode',             '$phone',             '$fax',             '$email')";   $insert = mysql_query($query2)     or (mysql_error());   $custid = mysql_insert_id(); } //If custid exists, we want to make it equal to custnum //Otherwise we will use the existing custnum if ($custid) {   $customers_custnum = $custid; } //2) Insert Info into ordermain //determine shipping costs based on order total (25% of total) $shipping = $total * 0.25; $query3 = "INSERT INTO ordermain (           ordermain_orderdate, ordermain_custnum,           ordermain_subtotal,ordermain_shipping,           ordermain_shipfirst, ordermain_shiplast,           ordermain_shipadd1, ordermain_shipadd2,           ordermain_shipcity, ordermain_shipcounty,           ordermain_shippostcode, ordermain_shipphone,           ordermain_shipemail)           VALUES (           '$today',           '$customers_custnum',           '$total',           '$shipping'           '$shipfirst',           '$shiplast',           '$shipadd1',           '$shipadd2',           '$shipcity',           '$shipcounty',           '$shippostcode',           '$shipphone',           '$shipemail')"; $insert2 = mysql_query($query3)   or (mysql_error()); $orderid = mysql_insert_id(); //3) Insert Info into orderdet //find the correct cart information being temporarily stored $query = "SELECT * FROM carttemp WHERE carttemp_sess='$sessid'"; $results = mysql_query($query)   or (mysql_error()); //put the data into the database one row at a time while ($row = mysql_fetch_array($results)) {   extract($row);   $query4 = "INSERT INTO orderdet (             orderdet_ordernum, orderdet_qty, orderdet_prodnum)             VALUES (             '$orderid',             '$carttemp_quan',             '$carttemp_prodnum')";   $insert4 = mysql_query($query4)     or (mysql_error()); } //4)delete from temporary table $query = "DELETE FROM carttemp WHERE carttemp_sess='$sessid'"; $delete = mysql_query($query); //5)email confirmations to us and to the customer /* recipients */ $to = "<" . $email .">"; /* subject */ $subject = "Order Confirmation"; /* message */   /* top of message */   $message = "     <html>     <head>     <title>Order Confirmation</title>     </head>     <body>     Here is a recap of your order:<br><br>     Order date: ";   $message .= $today;   $message .= "     <br>     Order Number: ";   $message .= $orderid;   $message .= "     <table width=\"50%\" border=\"0\">       <tr>         <td>           <p>Bill to:<br>";   $message .= $firstname;   $message .= " ";   $message .= $lastname;   $message .= "<br>";   $message .= $add1;   $message .= "<br>";   if ($add2) {     $message .= $add2 . "<br>";   }   $message .= $city . ", " . $county . "  " . $postcode;   $message .= "</p></td>     <td>       <p>Ship to:<br>";   $message .= $shipfirst . " " . $shiplast;   $message .= "<br>";   $message .= $shipadd1 . "<br>";   if ($shipadd2) {     $message .= $shipadd2 . "<br>";   }   $message .= $shipcity . ", " . $shipcounty . "  " . $shippostcode;   $message .= "</p>         </td>       </tr>     </table>     <hr width=\"250px\" align=\"left\">     <table cellpadding=\"5\">"; //grab the contents of the order and insert them //into the message field $query = "SELECT * FROM orderdet WHERE orderdet_ordernum = '$orderid'"; $results = mysql_query($query)   or die (mysql_query()); while ($row = mysql_fetch_array($results)) {   extract($row);   $prod = "SELECT * FROM products           WHERE products_prodnum = '$orderdet_prodnum'";   $prod2 = mysql_query($prod);   $prod3 = mysql_fetch_array($prod2);   extract($prod3);   $message .= "<tr><td>";   $message .= $orderdet_qty;   $message .= "</td>";   $message .="<td>";   $message .= $products_name;   $message .= "</td>";   $message .= "<td align=\"right\">";   $message .= $products_price;   $message .= "</td>";   $message .= "<td align=\"right\">";   //get extended price   $extprice = number_format($products_price * $orderdet_qty, 2);   $message .= $extprice;   $message .= "</td>";   $message .= "</tr>"; }   $message .= "<tr>     <td colspan=\"3\" align=\"right\">       Your total before shipping is:     </td>     <td align=\"right\">";   $message .= number_format($total, 2);   $message .= "       </td>     </tr>     <tr>       <td colspan=\"3\" align=\"right\">         Shipping Costs:       </td>       <td align=\"right\">";   $message .= number_format($shipping, 2);   $message .= "       </td>     </tr>     <tr>       <td colspan=\"3\" align=\"right\">         Your final total is:       </td>       <td align=\"right\"> ";   $message .= number_format(($total + $shipping), 2);   $message .= "         </td>       </tr>     </table>     </body>     </html>"; /* headers */ $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: <storeemail@email.com>\r\n"; $headers .= "Cc: <storeemail@email.com>\r\n"; $headers .= "X-Mailer: PHP / ".phpversion()."\r\n"; /* mail it */ mail($to, $subject, $message, $headers); //6)show them their order & give them an order number echo "Step 1 - Please Enter Billing and Shipping Information<br>"; echo "Step 2 - Please Verify Accuracy and Make Any Necessary Changes<br>"; echo "<strong>Step 3 - Order Confirmation and Receipt</strong><br><br>"; echo $message; ?> <form action="action.php" method=POST>       OrderID <input type="text" name="cartId" value="<?php echo $_POST['orderid']; ?>"><br />       Names<input name="name" type="text" value="<?php echo $_POST['firstname']; ?> <?php echo $_POST['lastname']; ?>" maxlength="500"><br />   Products Purchased<input type="text" name="desc" value="<?php echo $_POST['products_name']; ?>"><br />     Email <input name="email" type="text" value="<?php echo $_POST['email']; ?>" maxlength="50">    </td><br />   <input type=submit value="Confirm Order"> </form> [/code] I've cut out some of the form which is working ok, but orderid and products_name isnt being echoed into the form from above, however when it runs orderid and products_name work ok in the section within the first large php tag. Anyone able to see what I'm doing wrong? The only thing I can think of is that its looking at the wrong database table, therefor not finding it? Any help greatly appreciated.
  5. Thanks Tom, Looking at it, I think constructed it ok, its just it doesnt like the strip_slashes comment [quote]Fatal error: Call to undefined function: strip_slashes()[/quote] Any ideas to why it would do that, or what I've done to create it! [b]Edit - Never mind, I noticed the _ in the function that wasnt needed - seems to be working as expected so far![/b]
  6. Hi Everyone, I'm having a bit of touble with a drop down menu, what I'd like to do it have a drop down menu which shows 5 items: Saturday 9th December Sunday 10th December Saturday 16th December Sunday 17th December Saturday 23rd December and I'd like to run a slightly different query depending on which one is selected. So for example choosing the first one would run this query and display results: [code] <?php //connect to the database - either incoude a connection variable file or //type the following lines: $connect = mysql_connect ("localhost", "mysqlusername", "mysqlspassword") or die ("Connection to Database Failed."); mysql_select_db("eventsdb"); $query = "SELECT * FROM products WHERE products_eventdate = '2006-12-09'"; $results = mysql_query($query) or die(mysql_error()); ?>[/code] and the 2nd one would run this: [code]<?php //connect to the database - either incoude a connection variable file or //type the following lines: $connect = mysql_connect ("localhost", "mysqlusername", "mysqlspassword") or die ("Connection to Database Failed."); mysql_select_db("eventsdb"); $query = "SELECT * FROM products WHERE products_eventdate = '2006-12-10'"; $results = mysql_query($query) or die(mysql_error()); ?>[/code] Could anyone explain, or point me to a way of doing this? I can only find tutorials so far which populate the drop down from the DB and I dont think I need to be doing that! The queries all work if I setup different pages - so I know that the query is working ok. Many thanks for any help
×
×
  • 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.