iceblox Posted August 13, 2008 Share Posted August 13, 2008 Hi Guys, Im stuck on this query and was wondering if someone could check to make sure it is all ok? $querytotal = "SELECT * FROM deals_merch a, deals_deals g, deals_models i, deals_gifts f, deals_tariffs j WHERE g.ModelID = i.ModelID AND g.MerchantID = a.MerchantID AND g.TariffID = j.TariffID AND g.GiftID = f.GiftID AND g.TariffID <> '0' AND g.ModelID <> '0' $net3 $net $net1 $net2 $net4 $net6 $net7 $net8 $net9 LIMIT $limitvalue, $limit"; $resulttotal = mysql_query($querytotal) or die(mysql_error()); while ($row2 = mysql_fetch_array($resulttotal)) { Cheers, Phil Link to comment https://forums.phpfreaks.com/topic/119546-solved-php-query/ Share on other sites More sharing options...
Barand Posted August 13, 2008 Share Posted August 13, 2008 So what's your problem? What is it doing that that it shouldn't do? What is it not doing that it should? Is there a problem at all? We aren't psychic here so why don't you echo $querytotal; and post the output from that as (believe it or not) we have no idea what is in all those variables inside the query. Link to comment https://forums.phpfreaks.com/topic/119546-solved-php-query/#findComment-615870 Share on other sites More sharing options...
iceblox Posted August 13, 2008 Author Share Posted August 13, 2008 Aplologies Barand, Tried to do a quick post ;o) This is the out put SELECT * FROM deals_merch a, deals_deals g, deals_models i, deals_gifts f, deals_tariffs j WHERE g.ModelID = i.ModelID AND g.MerchantID = a.MerchantID AND g.TariffID = j.TariffID AND g.GiftID = f.GiftID AND g.TariffID <> '0' AND g.ModelID <> '0' AND i.ModelID = '276' AND j.Network = 'T-Mobile' Basically i have some IFs and ELSEs.. When i put $row2[MerchantID] != "8" If works but when i put if($row2[MerchantID] == "8") code] It doesnt work, MerchantID is in two different tables as per the table join. Could this be the reason that it doesnt work? Cheers, Phil Link to comment https://forums.phpfreaks.com/topic/119546-solved-php-query/#findComment-615877 Share on other sites More sharing options...
Barand Posted August 13, 2008 Share Posted August 13, 2008 That's one of the many reasons why "SELECT *" is a bad idea. Specify the fields required eg SELECT a.colname1, j.colname2 ... However, as you match on merchantID, the two values returned should be identical. Could it just be that there are no rows returned where the merchantID is 8? Link to comment https://forums.phpfreaks.com/topic/119546-solved-php-query/#findComment-615981 Share on other sites More sharing options...
iceblox Posted August 14, 2008 Author Share Posted August 14, 2008 Yeah its def in the results, I have checked every MerchantID and it just doesnt work if i do MerchantID == but if i do MerchantID != it works! But obviously doesnt give me the desire result.. Any ideas? Link to comment https://forums.phpfreaks.com/topic/119546-solved-php-query/#findComment-616354 Share on other sites More sharing options...
Barand Posted August 14, 2008 Share Posted August 14, 2008 Check the values aren't containing any spaces eg " 8" or "8 " try this to make sure var_dump($row2['MerchantID']); (And always put quotes round array string indexes) Link to comment https://forums.phpfreaks.com/topic/119546-solved-php-query/#findComment-616384 Share on other sites More sharing options...
iceblox Posted August 14, 2008 Author Share Posted August 14, 2008 Hi Barrand, I echod merchantid and it turns out that there was a lot wrong with the code i was using. So im gonna change the way that i wanted to do it. elseif($row[CashBack] != "0.00" OR $row[CashBack] != "0" OR $row[CashBack] != "") { $thissum =($row["Rental"] * $row["Length"]); $thatsum =$thissum - $row[CashBack]; $totalcostsum =$thatsum + $row["PhoneCost"]; mysql_query("UPDATE deals_deals SET TotalCost = '$totalcostsum' WHERE ModelID = '$ModelID'"); $reason1 = "2"; } Is this a valid statement? More so the mysql_query part? The idea is that when it matches on the if statments it will update the Totalcost into the data base but the Insert doesent seem to be working. Link to comment https://forums.phpfreaks.com/topic/119546-solved-php-query/#findComment-616442 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.