Jump to content

Recommended Posts

The $p1 / $p2 etc variables are all defined:

 

 

<?php
			$sql = "SELECT p1_pts = IF(p1_id=$p1), p2_pts = IF(p2_id=$p2), p3_pts = IF(p3_id=$p3), p4_pts = IF(p4_id=$p4), p5_pts = IF(p5_id=$p5), p6_pts = IF(p6_id=$p6), p7_pts = IF(p7_id=$p7), p8_pts = IF(p8_id=$p8) FROM races WHERE race_id = $race_id";
				mysql_query($sql);
				if(mysql_num_rows($result)!=0) {											
			while(list($pts_in_1st) = mysql_fetch_row($result)) {			
echo $pts_in_1st;
}
}

?>

 

Can anyone see what's wrong? Thanks. :(

Link to comment
https://forums.phpfreaks.com/topic/64393-sql-query-if-issue/
Share on other sites

Recommended solution:

 

Normalise the table then "SELECT pts WHERE player = $pl AND race_id = $race_id".

 

But to get you out of the mess you're in with a design like that

SELECT CASE $pl 
         WHEN p1_id THEN p1_pts
         WHEN p2_id THEN p2_pts
         WHEN p3_id THEN p3_pts
         WHEN p4_id THEN p4_pts
         WHEN p5_id THEN p5_pts
         WHEN p6_id THEN p6_pts
         WHEN p7_id THEN p7_pts
         WHEN p8_id THEN p8_pts
         ELSE 0 END
         as pts
FROM races 
WHERE race_id = $race_id

Link to comment
https://forums.phpfreaks.com/topic/64393-sql-query-if-issue/#findComment-321161
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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