Jump to content

[SOLVED] Query above and bellow number


thecase

Recommended Posts

Hi,

 

Im making a game. I have a the teams points as a variable $teampoints now this for example reads 5 I want to echo out just 2 teams, the one bellow 5 and the above 5 in a dropdown. If there is more than one team at 4 then let SQL/PHP pick any it doesnt really matter. If there is no lower just above or vice versa, then just take that 1 value.

 

How can I do this

Thanks

Link to comment
https://forums.phpfreaks.com/topic/119560-solved-query-above-and-bellow-number/
Share on other sites

Hmm I notice a problem this is the query I set up

 

$currentpointsp = "$ladderd$p";

$fetchpoints = "SELECT * FROM aacl_team WHERE teamname='$teamnamme'" or trigger_error("Query: $fetchpoints\n<br />MySQL Error: ". mysql_error());
$fetchpoints2 = mysql_query ($fetchpoints);
while ($fetchpoints3 = mysql_fetch_assoc($fetchpoints2)) {
$currentpoints = $fetchpoints3["$currentpointsp"]; 

$lesscurrentpoints = $currentpoints - 1;

$fetchmorepoints = "SELECT * FROM aacl_team WHERE $ladder='0' AND $currentpointsp=$lesscurrentpoints" or trigger_error("Query: $fetchmorepoints\n<br />MySQL Error: ". mysql_error());
$fetchmorepoints2 = mysql_query ($fetchmorepoints);
while ($fetchmorepoints3 = mysql_fetch_assoc($fetchmorepoints2)) {
$morepointteam = $fetchmorepoints3['teamname']; 
$morepointteamid = $fetchmorepoints3['id']; 

$morecurrentpoints = $currentpoints + 1;

$fetchlesspoints = "SELECT * FROM aacl_team WHERE $ladder='0' AND $currentpointsp=$morecurrentpoints" or trigger_error("Query: $fetchlesspoints\n<br />MySQL Error: ". mysql_error());
$fetchlesspoints2 = mysql_query ($fetchlesspoints);
while ($fetchlesspoints3 = mysql_fetch_assoc($fetchlesspoints2)) {
$lesspointteam = $fetchlesspoints3['teamname']; 
$lesspointteamid = $fetchlesspoints3['id']; 

 

now if the team has 5 points team 2 have 4 it displays that but if the next highest team only has 10 it will not display it its looking for 6 ... how can I make it search for the next lowest from 5 and vice versa.

 

Thanks

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.