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
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

Link to comment
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.