Jump to content

[SOLVED] SQL Statement


DeanWhitehouse

Recommended Posts

My function returns blank

<?php
function get_rank($exp)
{
$sql = "SELECT * FROM rank WHERE start >= '".$exp."' AND end <= '".$exp."'";
$sql = mysql_query($sql);
$sql = mysql_fetch_assoc($sql);
return $sql['rank'];
}
?>

And when debugged found out that the query is returning zero rows.

 

But the $exp is 0 and in the database

it looks like

id      rank        start    end

1  Rank 1  0  100

Link to comment
https://forums.phpfreaks.com/topic/138072-solved-sql-statement/
Share on other sites

I was just asking a simple question to make sure that you did not try to pull the wrong data. happens to the best of us. If $exp is 0 then it isn't going to return anything because

 

end <= '".$exp."'

 

$exp = 0

 

end = 100

 

100 is not less than or equal to 0.

Link to comment
https://forums.phpfreaks.com/topic/138072-solved-sql-statement/#findComment-721736
Share on other sites

I know how to @premiso i was asking what they would be

 

@revraz our rank table is

 

id rank start end

1 Rank 1 0 100

2 Rank 2 100 200

3 Rank 3 200 300

4 Rank 4 300 400

 

And what the user has is experience, e.g.

user1 has 0 exp (he has just joined)

but

user2 has 150 exp

@DarkerAngel, i think that has done it

Link to comment
https://forums.phpfreaks.com/topic/138072-solved-sql-statement/#findComment-721751
Share on other sites

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.