Jump to content

if query gets no result, do what...


villain222

Recommended Posts

Ok here's my problem,  I have a second query happening inside another While loop and I want it to grab info for the corresponding entry.  I can get it to work fine if there is and entry available.  So what do i do when the matching entry is not available.  I don't care that value is missing.  That's expected.  What I'm looking for is how handle the lack of the entry to specify the variables I want.

$final = mysql_query("SELECT tickets.item, tickets.amount, tickets.paypal FROM tickets WHERE tickets.item = $id"); //SECOND QUERY ON INCLUDE FILE
while ($row2=mysql_fetch_array($final)) {  //IF $id VALUE IS NOT MATCHED  I WANT $amount AND $paypalID TO = 0
$amount = $row2['amount'];
$paypalID = $row2['paypal'];}
if ($amount>0 && $paypalID>0){
echo $amount;
$over= '<font size=4 color="red"><br>sold!</font>';
echo $over;
$stop= "86";}
elseif ($hrdif>$hours) {
$payprice=$row['loprice'];
echo $payprice;
$over= '<font size=4 color="red"><br>sale over</font>';
echo $over;
$stop= "86";
//$userCut=$payprice*0.98;  -also on paypalIPN.php.  HERE FOR TESTING.
//echo $userCut;
}
else {
//echo "current price: ";
$payprice=round($row['price']-$hourly*$hrdif, 2);
echo $payprice;
$over= "";
$stop= "0";
}

Link to comment
https://forums.phpfreaks.com/topic/237289-if-query-gets-no-result-do-what/
Share on other sites

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.