Jump to content

error if nothing in database


techker

Recommended Posts

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/102422-error-if-nothing-in-database/
Share on other sites

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.");

   }?>

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.