Jump to content

stualk

Members
  • Posts

    109
  • Joined

  • Last visited

    Never

Everything posted by stualk

  1. Ok, previously I was using the code below. My order form was submitting the details to a file called 'order_form_submit.php' which is here... [code] <?php include "mime_mail.inc"; # create object instance $mail = new mime_mail; # set all data slots $mail->from = "$email"; $mail->to = "MY EMAIL ADDRESS HERE"; $mail->subject = "Order from the website"; $mail->body = "The following is an order from the website. The order details are as follows: NAME: $contact_name COMPANY: $company_name ADDRESS: $address TOWN: $town COUNTY: $county POST CODE: $post_code TELEPHONE: $telephone MOBILE: $mobile COMMENTS: $comments DESCRIPTION CODE QTY $brand_name $product_name $item_number $items "; # send email $mail->send(); print("<meta http-equiv=\"refresh\" content=\"1;URL=order_form_thank_you.php\"> "); ?> [/code]
  2. Problem is my order form already contains the client address and contact details. The hyperlink that takes the product details to the order form also takes the client details, so I need these details to be part of the email at the top really. Here's the content of the email I was using before, do I just put this beside the $body tag?: An order has been received. The order details are as follows: NAME: $contact_name COMPANY: $company_name ADDRESS: $address TOWN: $town COUNTY: $county POST CODE: $post_code TELEPHONE: $telephone MOBILE: $mobile COMMENTS: $comments
  3. Huggie, Yes, Yes, Yes! Works perfectly now, thank you, thank you, thank you!!! Let me buy you a drink...!!! Now for the last bit - the contents of the form then get submitted to a specified email account. Before I was using arrays I just had a long list of input boxes, each numbered like below. DESCRIPTION CODE QTY $desc1 $code1 $qty1 $desc2 $code2 $qty2 $desc3 $code3 $qty3 etc Now that i'm using an array how do I do this? Do I need to use the items field along with the id?
  4. Sorry, they do have a unique id. There is an id field which basically increments by 1 every time they add a new product to the database. I don't use this for anything though, I always call the item number. Shall I try using the id then? We can't be far away with this now because the error I mentioned above is showing all the item numbers every time I click a new item number, so it's clearly 'amost' working!
  5. Yes I did call my session 'items'. I have just re-added some code that I took out because I thought I didn't need it and I'm getting less errors now!The only error i'm getting in my order form now is this... Unable to run : SELECT * FROM products WHERE item_number IN (BO7407) < this is the item number I clicked on in my products page. Because: Unknown column 'BO7407' in 'where clause' Here's the code i'm using in my file order_form.php... [code] <?php session_start(); // clear the cart if the action is clear if ($_GET['action'] == "clear"){    unset($_SESSION['items']); } // if a link has been clicked if (isset($_GET['item_number'])){    if (!isset($_SESSION['items'][$_GET['item_number']])){       // if it the first time it's selected, quantity is 1       $_SESSION['items'][$_GET['item_number']] = 1;    }    else {       // if it's been selected before, increase it by 1       $_SESSION['items'][$_GET['item_number']]++;    } } // put the array of id's into a string for use in the sql query $sqlitems = implode(",", array_keys($_SESSION['items'])); // connect to the database include_once('database.php'); // run the query to get the product name from the database $sql = "SELECT * FROM products WHERE item_number IN ($sqlitems)"; $result = mysql_query($sql) or die ("<b>Unable to run :</b> $sql<br>\n<br>\n<b>Because:</b> " . mysql_error()); // echo a row for each of our product lines while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){    echo "<tr><td>{$row['$item_number']}</td><td><input type=\"text\" name=\"{$row['$item_number']}\" value=\"{$_SESSION['items'][$row['$item_number']]}\"></td></tr>\n"; } ?> [/code] Can you see anything obvious there that i've done wrong? It appears to be a problem with the Select from statement.
  6. Ok I've put the session start in that section and I'm still getting the same errors. These are the errors. I don't understand PHP errors at all, as you can probably tell: Warning: array_keys() [function.array-keys]: The first argument should be an array in URL on line 210 Warning: implode() [function.implode]: Bad arguments. in URL on line 210 Unable to run : SELECT * FROM products WHERE item_number IN () Because: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
  7. Ok thanks. I've put <?php session_start();?> at the top of every page but it still isn't working. I think now it's more a case of the rest of the code isn't in the right place (possibly but i'm not certain). This is the code i'm having difficulty with. It's in the file order_form.php. Can you spot anything obvious that i've done wrong? [code] <?php // put the array of id's into a string for use in the sql query $sqlitems = implode(",", array_keys($_SESSION['items'])); // connect to the database include_once('database.php'); // run the query to get the product name from the database $sql = "SELECT * FROM products WHERE item_number IN ($sqlitems)"; $result = mysql_query($sql) or die ("<b>Unable to run :</b> $sql<br>\n<br>\n<b>Because:</b> " . mysql_error()); // echo a row for each of our product lines while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){   echo "<tr><td>{$row['$item_number']}</td><td><input type=\"text\" name=\"{$row['id']}\" value=\"{$_SESSION['items'][$row['$item_number']]}\"></td></tr>\n"; } ?> [/code] By the way, my .inc files don't contain anything that might compromise security. All the database connection stuff is in a db.php file which I call in.
  8. I've got a bit lost with this code. I think i'm being a bit dumb. I tested the code in a page called products.php and it works fine. However, when I try it in my site I can't seem to get it right. It's a bit complicated too so let me try to explain... What i'm doing is using a page called index_client.php and then using .inc files to display the content of the site when each link is clicked. So, for example, the contact us link opens contact_us.inc, which contains the page content. So, the products listing is in a page called products_view.inc. When it displays the products I need a hyperlink from the item number to add the item numbers selected to the order form, which is a separate form (order_form.php). I'm getting a few errors and it's not quite working properly. I think this is because i've not put the code in the correct places to be honest. Does all the code above need to go in the order form page or does some go in product_view.inc? Sorry if that's confusing or sounds dumb but i'm a newbie so bear with me!
  9. Ok I put the code at the very top of the page and it seems to have got rid of one of the errors, but i'm still getting this one in a really small font at the top of the page. Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at URL:2) in URL on line 4
  10. Hello, I'm getting a couple of errors. Do you know what it means?... Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at URL:6) in URL on line 182 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at URL:6) in URL on line 182
  11. That's great. I think that's exactly what I need. I'll give that a try this evening and let you know how I get on. Thanks for this.
  12. Excellent, cheers. I also want the form to select the product name from the database using a select from query like this: "select product_name from DB where item_number = $item_number" and then display the product name beside the item number. I tried taking the product name as part of the hyperlink but because the names contain spaces it caused problems, so just the item number goes as part of the 'add to order' link.
  13. Yes there will be a quantity field on the order form. I was thinking maybe of automatically setting this to 0 for each item they order by default. The user should change the quantities themselves and then when they click submit I can use a javascript prompt to make sure there are no values left set at 0.
  14. Hi, I'm calling them in from a database and then just displaying them one below the other. There are a few sections so people will be browsing between these and selecting products from them so sessions variable sounds about right, although i've never dealt with those before either! I just need a hyperlink from the item number to then add it to a list if you like. Then at the end the user views the list and submits it.
  15. Hi Chaps, I posted about arrays last week regarding an online order form and got some useful responses pointing me in the direction of simple/free e-commerce packages. I've played around but nothing seems to be what i'm after. Can anyone advise me on the use of arrays because I've not worked with them much in the past? What I think I need to do is to store the item number of products in an array in a hidden page and then when people click 'View Order Form' it calls in the item numbers (and product names) of the items they selected from the array/hidden page. The form doesn't need to be any more sophisticated than that. It needs to send the order details by email but I think i've got that to work. There's no payment options or anything like that, I just need people to be able to click the item number and for it to remember what they've selected and eventually display them in the order form. Can anyone give me any advice on how best to do this? Thanks
  16. I want to do a 'SELECT * from db' query where the database contains certains words. How do I do this? For example, in pseudo: "Select* from db where FIELD contains the words 'word1','word2','word3'" etc Is this possible?
  17. stualk

    Arrays

    Hi Chaps, I posted about this before but didn't explain it properly. If I have a PHP page displaying products from a database how can I create a separate order form that captures the item numbers of the products a customer selects? So far I have got this to work but the order form only captures one item number. If you then select another product to add to the order form it overwrites the previous one. I'm almost there but I think it's an array I need to use in the form, take a look at my code and see what you think. This is the hyperlink from the products page: [code]<a href=javascript:MM_openBrWindow('order_form.php?clientid=$clientid&&item_number=$item_number','enlarge','width=620,height=550,resizable=yes,status=no,toolbar=no,scrollbars=yes')><i>$item_number</i></a>[/code] And here's the code i'm using in the form... [code] <?php if ($action =="" || $action=="default") { print(" <form name=\"form1\" method=\"post\"> <input type=\"hidden\" name=\"action\" value=\"addscript\" size=\"20\"> <table width='580' border='1' cellpadding='2' cellspacing='0' bordercolor='#000000'>   <tr valign='top'>     <td width='70%'><div align='center'><font size='2'><strong>Product Description</strong></font></div>     </td>     <td width='15%'><div align='center'><font size='2'><strong>Product Code</strong></font></div></td>     <td width='15%'><div align='center'><font size='2'><strong>Quantity</strong></font></div></td>   </tr>   <tr>     <td width='70%'><input name='desc11' type='text' id='desc11' value='$product_name' size='50'></td>     <td width='15%'><div align='center'>       <input name='code11' type='text' id='code11' value='$item_number' size='20'>     </div></td>     <td width='15%'><div align='center'>       <input name='qty11' type='text' id='qty11' size='5'>     </div></td>   </tr>   <tr>     <td>&nbsp;</td>     <td><div align='center'>       <input type='submit' name='Submit' value='Submit Order'>     </div></td>     <td><div align='center'>       <input type='reset' name='Submit2' value='Reset'>     </div></td>   </tr> </table> </form> "); ?> [/code] What's the best way to make it capture more than one order? Thanks
  18. Hi Chaps, I have a site which calls in products from a database and displays them on a page. What I've now done is to create a hyperlink from the product code of each product to an order form, so effectively you can add an item to the order form. So far so good with this. The hyperlink takes the values '$item_number' and '$product_name' into the PHP order form. Up to now this works perfectly but people can only add one item to the order form. How can I make sure that my order form adds a new row and the relevant boxes each time someone updates their order by clicking on another item? Here's the code of the order form (I only have one row currently in the table that displays the products): [code] <?php print(" <form name=\"form1\" method=\"post\"> <input type=\"hidden\" name=\"action\" value=\"addscript\" size=\"20\"> <table width='580' border='1' cellpadding='2' cellspacing='0' bordercolor='#000000'>   <tr valign='top'>     <td width='70%'><div align='center'><font size='2'><strong>Product Description</strong></font></div>     </td>     <td width='15%'><div align='center'><font size='2'><strong>Product Code</strong></font></div></td>     <td width='15%'><div align='center'><font size='2'><strong>Quantity</strong></font></div></td>   </tr>   <tr>     <td width='70%'><input name='desc11' type='text' id='desc11' value='$product_name' size='45'></td>     <td width='15%'><div align='center'>       <input name='code11' type='text' id='code11' value='$item_number' size='20'>     </div></td>     <td width='15%'><div align='center'>       <input name='qty11' type='text' id='qty11' size='5'>     </div></td>   </tr>   <tr>     <td>&nbsp;</td>     <td><div align='center'>       <input type='submit' name='Submit' value='Submit Order'>     </div></td>     <td><div align='center'>       <input type='reset' name='Submit2' value='Reset'>     </div></td>   </tr> </table> </form> "); ?>[/code] Any know how best I can achieve this? Thanks
  19. That's exactly what I wanted, works a treat. Didn't realise it was so simple but thanks for that. Useful for the future that. Thanks.
  20. Hi Chaps, Does anyone know how to do a select from query where something is NOT 'something'? What i'm trying to do is to display products from a database where the product type is NOT 'something' (i.e. display all product types except 'something') Is this easy to do? Thanks
  21. Just figured out what the problem was and it wasn't the code despite hours of tearing my hair out! I hadn't specified an order number for some of the brands. I have been through and added order numbers for all of the brands and now everything works perfectly!! Thanks once again for your help, it's much appreciated - novices huh!!
  22. The brand_ordervalue field is correct. That's the field in products_table that specifies the order they should appear in. I gave the field a slightly different name to try and avoid any possible conflict. Do you think this could be causing me a problem?
  23. Hi Chaps, Got another query on this issue I had last week. The above all worked fine when viewing by product brand but there is another part of the site that i'm working on where people can also view products by product type. Once you have selected the product type it should display the products in brand order from the brands table (in a similar way to above where the products are displayed in type order from the product types table - this works perfectly). Using the same code but changing the obvious bits so that it is relevant to the brand order rather than type order, it isn't quite working. The code i'm using is below. I can't think for the life of me why this isn't working. The order the products are being displayed seems a bit random rather than displaying in brand order. Can anyone see what might be wrong with this code... [code]$NumRows=mysql_query("SELECT * FROM products_table where product_type='$product_type'&&visible = 'Yes'"); $NumRows=mysql_num_rows($NumRows); $Result = mysql_query("SELECT p.*, t.* FROM products_table p, brands_table t WHERE p.brand_name = t.the_brand_name AND p.product_type = '$product_type' AND p.visible = 'Yes' ORDER BY t.brand_ordervalue"); if (!$Result) die (mysql_error()); for ($i=1; $i<=$NumRows; $i++) {   if ($row = mysql_fetch_array($Result)) { $id = $row["id"]; $brand_name = $row["brand_name"]; $product_name = $row["product_name"]; $item_number = $row["item_number"]; $description = $row["description"]; $product_thumbnail = $row["product_thumbnail"]; echo(" <tr valign='top'>     <td width='220' rowspan='3'><div align='left'><a href=javascript:MM_openBrWindow('image_enlarge.php?id=$row[id]','enlarge','width=740,height=575,resizable=yes,status=no,toolbar=no,scrollbars=yes')><img border='1' src='URL HERE/$product_thumbnail'></a></div></td>     <td><font size=\"2\"><b>$brand_name $product_name</b></font></td> </tr> <tr height='25' valign='top' align='left'>     <td valign='top'><font size=\"2\"><i>$item_number</i></font></td> </tr> <tr height='25' valign='top' align='left'> <td valign='top'><font size=\"2\">$description<br></font></td> </tr> <tr valign='top' align='left'> <td valign='top' width='180'><font color='#000000' face=\"Verdana\" size=\"2\"><br></font></td> <td><font size=\"2\"><br></font></td> </tr> "); }}} [/code] Thanks for your help.
  24. I can't believe that all my problems were due to a missing comma!!! That now works perfectly! Thank you very much for your help with this.
  25. Ah right, that tells me what the error is, excellent! Here's the error... You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '.ordervalue FROM products p, product_types t WHERE p.prod So there's something not quite right with the code I'm using in my query. I never use the type of code above so i'm not sure what part of the code is incorrect.
×
×
  • 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.