graham23s Posted February 17, 2008 Share Posted February 17, 2008 Hi Guys, in this piece of code: <?php // get the id // $categoryid = $_GET['id']; // query the db // $queryproduct = "SELECT * FROM `fcp_categories` WHERE `id`='$categoryid'"; $resultproduct = mysql_query($queryproduct) or die (mysql_error()); $row = mysql_fetch_array($resultproduct) or die (mysql_error()); // vars // $catname = $row['categoryname']; // set the rane // //$quantity = range(1,99); // get and display all the products associated with this cat // $queryproducts = "SELECT * FROM `fcp_products` WHERE `category_id`='$categoryid'"; $resultsproducts = mysql_query($queryproducts) or die (mysql_error()); // number of products // $numproducts = mysql_num_rows($resultsproducts); // standard header // print("<div class=\"subheader\"><div id=\"title\">Category > <span class=\"blue\">$catname</span></div>We have <b>$numproducts</b> products in this category for you to browse.</div>"); //--------------------------------------------// // need modulous to display them properly // $i = 0; // begin the table // print("<table class=\"products_table\" align=\"center\" width=\"100%\" border=\"0\" cellpadding=\"10\" cellspacing=\"0\">"); // start the while loop // while ($rows = mysql_fetch_array($resultsproducts)) { $productid = $rows['id']; $product_name = $rows['product_name']; $product_description = $rows['product_description']; $product_price = $rows['product_price']; // display box for products // $display_box = "<form action=\"shoppingcart.php\" method=\"get\">\n"; $display_box .= "<div id=\"right\">\n"; $display_box .= "<div class=\"boxtop\">\n"; $display_box .= "</div>"; $display_box .= "<div class=\"box\">"; $display_box .= "<img src=\"images/image.gif\" alt=\"Product Image\" title=\"Product Image\" class=\"image\" />\n"; $display_box .= "<b>$product_name</b>"; $display_box .= "<br />"; $display_box .= "<br />"; $display_box .= "$product_description"; $display_box .= "<br />"; $display_box .= "<hr />"; $display_box .= "<input type=\"hidden\" name=\"productid\" value=\"$productid\" />"; $display_box .= "<input type=\"image\" src=\"images/cart_navy.gif\" border=\"0\" alt=\"Add this item to your shopping cart!\">"; $display_box .= "<hr />"; $display_box .= "Our Price <span class=\"price\">£$product_price</span>"; $display_box .= "<br />"; $display_box .= "<hr />"; $display_box .= "<b>Quantity:</b> "; $display_box .= "<select name=\"orderquantity\">"; $display_box .= "<option value=\"1\">1</option>"; $display_box .= "<option value=\"2\">2</option>"; $display_box .= "<option value=\"3\">3</option>"; $display_box .= "<option value=\"4\">4</option>"; $display_box .= "<option value=\"5\">5</option>"; $display_box .= "</select>"; $display_box .= "</div>\n"; $display_box .= "</div>\n"; $display_box .= "</div>\n"; $display_box .= "</form>\n"; if ($i==0) { print('<tr><td align="center">'.$display_box.'</td>'); } elseif ($i == 2) { print('<td align="center">'.$display_box.'</td></tr>'); } else { print('<td align="center">'.$display_box.'</td>'); } $i++; $i=$i % 2; // mod 2 gives you the remainder // } // end the while loop // // end the products tabel // print("</tr>"); print("</table>"); // show the button if the session is set // // buttons // if(isset($_SESSION['id'])) { $session_id = $_SESSION['id']; // query the databse if the session id has products in the basket show the button // $q = "SELECT `customer_id` FROM `fcp_orders` WHERE `customer_id`='$session_id'"; $r = mysql_query($q); if(mysql_num_rows($r) > 0) && ($numproducts > 0) { print("<hr width=\"50%\">"); print("<form action=\"checkout.php\" method=\"get\">"); print("<table width=\"95%\" border=\"0\">"); print("<tr>"); print("<td align=center><img src=\"images/cards.bmp\" alt=\"Payments we accept!\"></td>"); print("<td align=center><input type=\"submit\" value=\"Proceed to Checkout\" style=\"font-weight: bold; font-size: 120%;\"></td>"); print("</table>"); print("</form>"); } } ?> at the bottom i have: // show the button if the session is set // // buttons // if(isset($_SESSION['id'])) { $session_id = $_SESSION['id']; // query the databse if the session id has products in the basket show the button // $q = "SELECT `customer_id` FROM `fcp_orders` WHERE `customer_id`='$session_id'"; $r = mysql_query($q); if(mysql_num_rows($r) > 0) && ($numproducts > 0) { print("<hr width=\"50%\">"); print("<form action=\"checkout.php\" method=\"get\">"); print("<table width=\"95%\" border=\"0\">"); print("<tr>"); print("<td align=center><img src=\"images/cards.bmp\" alt=\"Payments we accept!\"></td>"); print("<td align=center><input type=\"submit\" value=\"Proceed to Checkout\" style=\"font-weight: bold; font-size: 120%;\"></td>"); print("</table>"); print("</form>"); } } i want to show a checkout button only if the session is set, and the category contains more items than 0 but i get: unexpected T_BOOLEAN_AND in /home/.castle/graham23s/www.site.co.uk/categories.php on line 115 can anyone see any problems with my show button syntax at all? thanks guys Graham Link to comment https://forums.phpfreaks.com/topic/91519-syntax-and-logic-help/ Share on other sites More sharing options...
uniflare Posted February 17, 2008 Share Posted February 17, 2008 try replacing this line: if(mysql_num_rows($r) > 0) && ($numproducts > 0) with this: if(mysql_num_rows($r) > 0 && $numproducts > 0) Link to comment https://forums.phpfreaks.com/topic/91519-syntax-and-logic-help/#findComment-468785 Share on other sites More sharing options...
graham23s Posted February 17, 2008 Author Share Posted February 17, 2008 perfect thanks mate i knew the syntax was off. cheers Graham Link to comment https://forums.phpfreaks.com/topic/91519-syntax-and-logic-help/#findComment-468786 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.