techker Posted April 22, 2008 Share Posted April 22, 2008 hey guys i was woundering if any body can point me in the right direction. so i have a database that store information of clients like when orders done in the shopping cart.so i recently made a box on the front page saying the last date the client ordered in the shopping cart. but he probleme im having is when there is nothing in there it gives no matches ..but the hole page gets messt up,even if i made it an include.. here is the page that hase the query (the include page) <?php // Connects to your Database mysql_connect("localhost", "kk", "hhh") or die(mysql_error()); mysql_select_db("hhh") or die(mysql_error());?> <?php $QQQ1 = mysql_query("SELECT c.NoCommande AS NoCommande, d.Quantite AS Quantite, c.UName AS Usager, c.DateCommande AS Date, p.SkuFabriquant AS Sku, p.DescriptionCourte AS NomProduit FROM tblCommande AS c LEFT JOIN ( tblCommandeDetail AS d CROSS JOIN tblProduits AS p ) ON ( p.IDProduit = d.IDProduit AND d.NoCommande = c.NoCommande ) WHERE c.UName = '$USERNAME' ORDER BY Date LIMIT 1 , 1 "); if(!$QQQ1) die(mysql_error()); $err = mysql_num_rows($QQQ1); if($err == 0) die("No matches met your criteria.");?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- .echo2 { color: 000000; text-decoration: none; } --> </style> </head> <body> <?php while ($info=mysql_fetch_array($QQQ1)) { echo "</b><br> </i>"; echo "<span class='echo2'>".$info['Date']."</span>"; } ?> </body> </html> so it only put the last date.in the box i made.i don't know if im clear lol Quote Link to comment Share on other sites More sharing options...
phpSensei Posted April 22, 2008 Share Posted April 22, 2008 try <?php $QQQ1 = mysql_query("SELECT c.NoCommande AS NoCommande, d.Quantite AS Quantite, c.UName AS Usager, c.DateCommande AS Date, p.SkuFabriquant AS Sku, p.DescriptionCourte AS NomProduit FROM tblCommande AS c LEFT JOIN ( tblCommandeDetail AS d CROSS JOIN tblProduits AS p ) ON ( p.IDProduit = d.IDProduit AND d.NoCommande = c.NoCommande ) WHERE c.UName = '$USERNAME' ORDER BY Date LIMIT 1 , 1 "); if(!$QQQ1){ $err = mysql_num_rows($QQQ1); } if($err == 0){ die("No matches met your criteria."); }?> Quote Link to comment Share on other sites More sharing options...
techker Posted April 22, 2008 Author Share Posted April 22, 2008 it gives me a blanc page?thx! Quote Link to comment Share on other sites More sharing options...
phpSensei Posted April 22, 2008 Share Posted April 22, 2008 Remove all of your "or die(mysql_error())" and "die(error....)" Quote Link to comment Share on other sites More sharing options...
techker Posted April 22, 2008 Author Share Posted April 22, 2008 you mean in my connection?if so it does the same. Quote Link to comment Share on other sites More sharing options...
phpSensei Posted April 22, 2008 Share Posted April 22, 2008 Then your php has an error which you do not see. try error_reporting(E_ALL) Quote Link to comment Share on other sites More sharing options...
techker Posted April 22, 2008 Author Share Posted April 22, 2008 were do i put that? Quote Link to comment Share on other sites More sharing options...
phpSensei Posted April 22, 2008 Share Posted April 22, 2008 top of the page. Quote Link to comment Share on other sites More sharing options...
techker Posted April 22, 2008 Author Share Posted April 22, 2008 i put it in the top ? error_reporting(E_ALL) ?> and it still gives me a blanc? i know the page is good cause i have an echo user name and i see it Quote Link to comment Share on other sites More sharing options...
fenway Posted April 23, 2008 Share Posted April 23, 2008 Well, let's see $QQQ1. What makes you think there are matching rows? Quote Link to comment Share on other sites More sharing options...
techker Posted April 23, 2008 Author Share Posted April 23, 2008 puzzled? Quote Link to comment Share on other sites More sharing options...
fenway Posted April 23, 2008 Share Posted April 23, 2008 puzzled? Echo $QQQ1. Have you run this query from the CLI or phpmyadmin? Perhaps it's correct. Also, why the cross join? Quote Link to comment Share on other sites More sharing options...
techker Posted April 23, 2008 Author Share Posted April 23, 2008 it was working perfectly.they only thing is when ia new user joined it mess t up my front page cause he had no orders in the catalogue. Quote Link to comment Share on other sites More sharing options...
fenway Posted April 24, 2008 Share Posted April 24, 2008 Then you need a LEFT JOIN. Quote Link to comment Share on other sites More sharing options...
techker Posted April 24, 2008 Author Share Posted April 24, 2008 SELECT c.NoCommande AS NoCommande, d.Quantite AS Quantite, c.UName AS Usager, c.DateCommande AS Date, p.SkuFabriquant AS Sku, p.DescriptionCourte AS NomProduit FROM tblCommande AS c LEFT JOIN ( tblCommandeDetail AS d CROSS JOIN tblProduits AS p ) ON ( p.IDProduit = d.IDProduit AND d.NoCommande = c.NoCommande ) WHERE c.UName = '$USERNAME' ORDER BY Date LIMIT 1 , 1 "); it is there? Quote Link to comment Share on other sites More sharing options...
fenway Posted April 25, 2008 Share Posted April 25, 2008 I'm sorry, I thought there was a problem with the sql... maybe it the PHP code that's wrong... does the page work without tha twhile loop? Quote Link to comment Share on other sites More sharing options...
techker Posted April 25, 2008 Author Share Posted April 25, 2008 could it be the limit 1.1 cause it grabs only the last query? Quote Link to comment Share on other sites More sharing options...
fenway Posted April 26, 2008 Share Posted April 26, 2008 We're going in circles here... you currently have a blank page, right? Quote Link to comment Share on other sites More sharing options...
techker Posted April 27, 2008 Author Share Posted April 27, 2008 yes.it does not show anything. Quote Link to comment Share on other sites More sharing options...
fenway Posted April 28, 2008 Share Posted April 28, 2008 So comment out all of the php code until it doesn't. Start with the query and anything downstream... just leave the DB connect. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.