Jump to content

westminster86

Members
  • Posts

    128
  • Joined

  • Last visited

    Never

Everything posted by westminster86

  1. The script provides a link to each product in a category. Each link is suffixed with a parameter. This time around, its the productid for the product in question. im having trouble retrieving images of the server. if (file_exists('images/'.$row['productid'].'.jpg')) The directory is... /htdocs/images any ideas?
  2. function display_products($product_array) { // display all products in the array passed in if (!is_array($product_array)) { echo '<br />No products currently available in this category<br />'; } else { echo '<table border = "0" width = "30%">'; // create a table row for each product foreach ($product_array as $row) { $url = 'showProduct.php?productid='.($row['productid']); echo '<tr><td>'; if (@file_exists($row['productid'].'.jpg')) { $size = GetImageSize($row['productid'].'.jpg'); if ($size[0]>0 && $size[1]>0) { $image = '<img src="'.($row['productid']).'.jpg" border="0" width = '. $size[0]/4 .' height = '. $size[1]/4 .' />'; do_html_url($url, $image); } } else { echo ' '; } echo '</td><td>'; $name = $row['name']; $price = $row['price']; do_html_url($url, $name); echo 'Price: £'.$row['price']; echo '</td></tr>'; } echo '</table>'; } echo '<hr />'; } thats displaying them in a single colum with the product name a url and the price of the item underneath the item because the indices in the array are not numbers, i cant use a counter so how can i use a for loop?
  3. function display_products($product_array) { // display all products in the array passed in if (!is_array($product_array)) { echo '<br />No products currently available in this category<br />'; } else { echo '<table border = "0" width = "30%">'; // create a table row for each product foreach ($product_array as $row) { $url = 'showProduct.php?productid='.($row['productid']); echo '<tr><td>'; if (@file_exists($row['productid'].'.jpg')) { $size = GetImageSize($row['productid'].'.jpg'); if ($size[0]>0 && $size[1]>0) { $image = '<img src="'.($row['productid']).'.jpg" border="0" width = '. $size[0]/4 .' height = '. $size[1]/4 .' />'; do_html_url($url, $image); } } else { echo ' '; } echo '</td><td>'; $name = $row['name']; $price = $row['price']; do_html_url($url, $name); echo 'Price: £'.$row['price']; echo '</td></tr>'; } echo '</table>'; } echo '<hr />'; } thats displaying them in a single colum with the product name a url and the price of the item underneath the item
  4. It probably doesn't matter, but then again, I'm not 100% sure I know what you're doing. im trying to display images on the webpage, which i have working but i want to change the layout. there currently being displayed one underneath the other in a single colum. ive stored the images on the server. can someone help me out because ive been trying to change my coding around to the post that thorpe posted but im nt getting nehwre
  5. It probably doesn't matter, but then again, I'm not 100% sure I know what you're doing. im trying to display images on the webpage, which i have working but i want to change the layout. there currently being displayed one underneath the other in a single colum. ive stored the images on the server.
  6. Or a while loop, which would probably be better. Hint: You can use modulo which may or may not help you depending on whether or not you know how to utilize it. nah i dnt... so ill give that one a miss.. thanks ill try with a while loop i havent stored my images in the database, ive just uploaded them to the server does that matter?
  7. Or a while loop, which would probably be better. Hint: You can use modulo which may or may not help you depending on whether or not you know how to utilize it. nah i dnt... so ill give that one a miss.. thanks ill try with a while loop
  8. Could i also use a for loop to do this? because im getting the results directly from an array. Im just getting the same outputs as i ddi before even though im using a counter
  9. i have a page that displays images acording to what category the user has selected. However, the images are being displayed in a single column...so one underneath the other. how can i display the images for instance showing 4 across the page and another 4 underneath and so on. And how do i show say only 12 images per page. heres the current coding.. function display_products($product_array) { // display all products in the array passed in if (!is_array($product_array)) { echo '<br />No products currently available in this category<br />'; } else { echo '<table border = "0" width = "30%">'; // create a table row for each product foreach ($product_array as $row) { $url = 'showProduct.php?productid='.($row['productid']); echo '<tr><td>'; if (@file_exists($row['productid'].'.jpg')) { $size = GetImageSize($row['productid'].'.jpg'); if ($size[0]>0 && $size[1]>0) { $image = '<img src="'.($row['productid']).'.jpg" border="0" width = '. $size[0]/4 .' height = '. $size[1]/4 .' />'; do_html_url($url, $image); } } else { echo ' '; } echo '</td><td>'; $name = $row['name']; $price = $row['price']; do_html_url($url, $name); echo 'Price: £'.$row['price']; echo '</td></tr>'; } echo '</table>'; } echo '<hr />'; }
  10. didnt think of tht... thanks ok ive found the statements in the function that are casuing the function to return false You will see that different parts of the insert are enclosed in a transaction beginning with $db->autocommit(FALSE) and ending with $db->commit(); $db->autocommit(TRUE); the message returned is... Fatal error: Call to a member function on a non-object what am i doing wrong?
  11. didnt think of tht... thanks
  12. im just using the function that ive got out of a book and ive changed a few things around. ive checked my tables and its adding the customer details so im guessing thats its returning false somewher after these statements
  13. im just using the function that ive got out of a book and ive changed a few things around. ive checked my tables and its adding the customer details so im guessing thats its returning false somewher after these statements
  14. im just using the function that ive got out of a book and ive changed a few things around.
  15. yeh im doing that now. looking at each line. probably missing a comma or something somwhere can anyone see anything wrong here, cos i been looking for past 2 hours and i just cnt see nething :-\ ok found couple things that i missed out.. missed a few dollar signs and got one of my tabl names wrong but still isnt working....YET :'(
  16. yeh im doing that now. looking at each line. probably missing a comma or something somwhere can anyone see anything wrong here, cos i been looking for past 2 hours and i just cnt see nething :-\
  17. yeh im doing that now. looking at each line. probably missing a comma or something somwhere
  18. yeh i changed that around... still no joy if i was to change it to !=true then it works fine, but then none of the values get added to the database.
  19. i dnt think it really matters... '' works just as good as Null does. But i did try changing it around but its echoing the else statement could not store data.
  20. The line, if(insert_order($_POST)!=false) is evaluating to false for some reason. There maybe something wrong with the function. Any ideas. <?php // The shopping cart needs sessions, so start one session_start(); do_html_header('Checkout'); // create short variable names $title = $_POST['title']; $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $address = $_POST['address']; $city = $_POST['city']; $postcode = $_POST['postcode']; $country = $_POST['country']; // if filled out if($_SESSION['cart']&&$title&&$firstname&&$lastname&&$address&&$city&&$postcode&&$country) { // able to insert into database if(insert_order($_POST)!=false) { // display cart, not allowing changes and without pictures display_cart($_SESSION['cart'], false, 0); display_shipping(10); // get credit card details display_card_form($name); display_button('showCart.php', 'continue-shopping', 'Continue Shopping'); } else { echo 'Could not store data, please try again.'; echo $title; echo $firstname; echo $lastname; echo $address; echo $city; echo $postcode; echo $country; display_button('checkout.php', 'back', 'Back'); } } else { echo 'You did not fill in all the fields, please try again.<hr />'; display_button('checkout.php', 'back', 'Back'); } do_html_footer(); function insert_order($order_details) { // extract order_details out as variables extract($order_details); $shiptitle = $_POST['shiptitle']; $shipfirstname = $_POST['shipfirstname']; $shiplastname = $_POST['shiplastname']; $shipaddress = $_POST['shipaddress']; $shipcity = $_POST['shipcity']; $shippostcode = $_POST['shippostcode']; $shipcountry = $_POST['shipcountry']; // set shipping address same as address if(!$shiptitle&&!$shipfirstname&&!$shiplastname&&!$shipaddress&&!$shipcity&&!$shippostcode&&!$shipcountry) { $shiptitle = $title; $shipfirstname = $firstname; $shiplastname = $lastname; $shipaddress = $address; $shipcity = $city; $shippostcode = $postcode; $shipcountry = $country; } @ $db = mysql_connect(''); mysql_select_db(''); // we want to insert the order as a transaction // start one by turning off autocommit //$db->autocommit(FALSE); // insert customer address $query = "select customerid from customers where title ='$title' and firstname = '$firstname' and lastname = '$lastname' and address = '$address' and city = '$city' and postcode = '$postcode' and country = '$country'"; $result = mysql_query($query); if(mysql_num_rows($result)>0) { $customer = $mysql_fetch_object($result); $customerid = $customer->customerid; } else { $query = "insert into customer values ('', '$title', '$firstname', '$lastname', '$address', '$city', '$postcode', '$country')"; $result = mysql_query($query); if (!$result) return false; } $customerid = $db->insert_id; $date = date('Y-m-d'); $query = "insert into orders values ('', $customerid, ".$_SESSION['total_price'].", '$date', '$shiptitle', '$shipfirstname', '$shiplastname', '$shipaddress', '$shipcity', '$shippostcode', '$shipcountry')"; $result = mysql_query($query); if (!result) return false; $query = "select orderid from orders where customerid = $customerid and amount > ".$_SESSION['total_price']."-.001 and amount > ".$_SESSION['total_price']."+.001 and date = '$date' and shiptitle = '$shiptitle' and shipfirstname = '$shipfirstname' and shiplastname = '$shiplastname' and shipaddress = '$shipaddress' and shipcity = '$shipcity' and shippostcode = '$shippostcode' and shipcountry = '$shipcountry'"; $result = mysql_query($query); if(mysl_num_rows($result)>0) { $order = $result->fetch_object(); $orderid = $order->orderid; } else return false; // insert each product foreach($_SESSION['cart'] as $productid => $quantity) { $detail = get_product_details($productid); $query = "delete from order_items where orderid = '$orderid' and productid = '$productid'"; $result = mysql_query($query); $query = "insert into order_items values ('$orderid', '$productid', ".$detail['price'].", $quantity, 1)"; $result = mysql_query($query); if(!result) return false; } // end transaction $db->commit(); $db->autocommit(TRUE); return $orderid; }?> (edited to insert tags)
  21. i c u have the book to thanks for your help dude... im pretty crap at this stuff. anyone know of any particular books that may be useful for starting out... i know the basics and stuff but was just looking at some sites and mines is just terrible compared.
  22. i c u have the book to thanks for your help dude... im pretty crap at this stuff.
  23. i didnt think about that... thats not guna do me ne good then :-\ u got ne suggestions to wht i shld do... hw cn i change the function?
  24. ok thanks for that ill try fidling around with that insert_order line then hey ginger seeing as it is returning false... how about if i just set it to true that way it would work...although not good programming practice
  25. ok thanks for that ill try fidling around with that insert_order line then
×
×
  • 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.