DaveLinger Posted July 15, 2006 Share Posted July 15, 2006 heres the code:[code]$pid = $_GET[pid];if($pid == ''){echo "No Platform ID Specified.";include('includes/footer.php');}ELSE{if($pid == '12'){$sqlthing = 'WHERE newsecid IN (12,34,35,36,37,38,40,41,42,43,45,46,48)';}if($pid == '13'){$sqlthing = 'WHERE newsecid IN (13,35,36,37,39,40,41,42,43,44,45,46,47)';}if($pid == '14'){$sqlthing = 'WHERE newsecid IN (14,34,35,36,37)';}if($pid == '20'){$sqlthing = 'WHERE newsecid IN (20,38,39,40,41,44,45,47)';}if($pid == '32'){$sqlthing = 'WHERE newsecid IN (32,41,42,44,45,47)';}if($pid == '16'){$sqlthing = 'WHERE newsecid IN (16,48)';}ELSE{$sqlthing = 'WHERE newsecid = $pid';}if (!$link = mysql_connect($sqlserver, $sqlusername, $sqlpassword)) { echo 'Could not connect to mysql'; exit;}if (!mysql_select_db($sqldatabase, $link)) { echo 'Could not select database'; exit;}$query="SELECT * FROM nuke_seccont $sqlthing AND fletter = 'A'";$result = mysql_query($query);while ($row = mysql_fetch_array($result)) {$title = stripslashes($row["title"]);$artid = stripslashes($row["artid"]);$counter = stripslashes($row["counter"]);echo "<tr> <td><b><a href=\"review.php?artid=$artid\" title=\"$counter hits\">$title</a></b></td> </tr>";$i++;}}?>[/code](It does that last bit of code once for each letter)No errors, but no results, from ANY of the values specified! Quote Link to comment https://forums.phpfreaks.com/topic/14641-where-column-in-valuevalue-problem/ Share on other sites More sharing options...
BillyBoB Posted July 15, 2006 Share Posted July 15, 2006 shouldnt it have mysql_querythen the WHERE section ? Quote Link to comment https://forums.phpfreaks.com/topic/14641-where-column-in-valuevalue-problem/#findComment-58283 Share on other sites More sharing options...
akitchin Posted July 15, 2006 Share Posted July 15, 2006 how are you building the query after that? have you tried echoing the query you end up with in the end (before running it)? Quote Link to comment https://forums.phpfreaks.com/topic/14641-where-column-in-valuevalue-problem/#findComment-58285 Share on other sites More sharing options...
BillyBoB Posted July 15, 2006 Share Posted July 15, 2006 [code]<?php$pid = $_GET[pid];if($pid == ''){echo "No Platform ID Specified.";include('includes/footer.php');}ELSE{if($pid == '12'){$sqlthing = mysql_query('WHERE newsecid IN (12,34,35,36,37,38,40,41,42,43,45,46,48)') or die(mysql_error());//shouldnt they all be like this//shouldnt they all be like this//shouldnt they all be like this}if($pid == '13'){$sqlthing = 'WHERE newsecid IN (13,35,36,37,39,40,41,42,43,44,45,46,47)';}if($pid == '14'){$sqlthing = 'WHERE newsecid IN (14,34,35,36,37)';}if($pid == '20'){$sqlthing = 'WHERE newsecid IN (20,38,39,40,41,44,45,47)';}if($pid == '32'){$sqlthing = 'WHERE newsecid IN (32,41,42,44,45,47)';}if($pid == '16'){$sqlthing = 'WHERE newsecid IN (16,48)';}ELSE{$sqlthing = 'WHERE newsecid = $pid';}if (!$link = mysql_connect($sqlserver, $sqlusername, $sqlpassword)) { echo 'Could not connect to mysql'; exit;}if (!mysql_select_db($sqldatabase, $link)) { echo 'Could not select database'; exit;}$query="SELECT * FROM nuke_seccont $sqlthing AND fletter = 'A'";$result = mysql_query($query);while ($row = mysql_fetch_array($result)) {$title = stripslashes($row["title"]);$artid = stripslashes($row["artid"]);$counter = stripslashes($row["counter"]);echo "<tr> <td><b><a href=\"review.php?artid=$artid\" title=\"$counter hits\">$title</a></b></td> </tr>";$i++;}}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14641-where-column-in-valuevalue-problem/#findComment-58290 Share on other sites More sharing options...
DaveLinger Posted July 15, 2006 Author Share Posted July 15, 2006 gar, I echoed the query and it is:"SELECT * FROM nuke_seccont WHERE newsecid = $pid AND fletter = '0-9'"but the $_GET[pid] is '12'X.X Quote Link to comment https://forums.phpfreaks.com/topic/14641-where-column-in-valuevalue-problem/#findComment-58296 Share on other sites More sharing options...
DaveLinger Posted July 15, 2006 Author Share Posted July 15, 2006 maybe there's something wrong with my if statement? pid=16 creates a correct query..."SELECT * FROM nuke_seccont WHERE newsecid IN (16,48) AND fletter = '0-9'" Quote Link to comment https://forums.phpfreaks.com/topic/14641-where-column-in-valuevalue-problem/#findComment-58299 Share on other sites More sharing options...
akitchin Posted July 15, 2006 Share Posted July 15, 2006 billybob, that will not fix the problem. running:[code]$sqlthing = mysql_query('WHERE newsecid IN (12,34,35,36,37,38,40,41,42,43,45,46,48)') or die(mysql_error());[/code]will yield a syntax EVERYTIME because 'WHERE newsecid IN (12,34,35,36,37,38,40,41,42,43,45,46,48)' is not a complete query. we appreciate you trying to help, but posting code that is totally erroneous only makes matters worse.davelinger: it's because your statement is wrong. it needs to be an if-elseif-else statement. as it stands, itll run each if() until it reaches the last if(), which is an if-else. since the if() condition fails there (because your pid is 12, not 16), it'll run the else{} statement whenever the pid isn't 16, which gives you your problem.change every if() after the first one to elseif(). alternatively, use a switch() statement:[code]<?phpswitch ($pid){ case 12: $sqlthing = 'WHERE newsecid IN (12,34,35,36,37,38,40,41,42,43,45,46,48)'; break; case 13: the line for 13; break; default: the WHERE clause to use if none of the cases is matched; break;}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14641-where-column-in-valuevalue-problem/#findComment-58302 Share on other sites More sharing options...
DaveLinger Posted July 15, 2006 Author Share Posted July 15, 2006 thank you. Quote Link to comment https://forums.phpfreaks.com/topic/14641-where-column-in-valuevalue-problem/#findComment-58306 Share on other sites More sharing options...
redarrow Posted July 15, 2006 Share Posted July 15, 2006 akitchin so fast beat me there lol......................dam!becouse i got beat from speedy here an example ok.// set a if condition.if(condition) {// set a else if condition.}elseif(condition){set another elseif condition.}elseif(condition){//set another elseif condition.}elseif(condition){//finally an else conndition.}else{echo" bla bla bla ";}please look at the format of else elseif else ok.good luck.ps. the speed was the age lol.............. Quote Link to comment https://forums.phpfreaks.com/topic/14641-where-column-in-valuevalue-problem/#findComment-58329 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.