Count return wrong?
I have an SQL query:
function players_check() {
$result3 = mysql_query("SELECT COUNT(`player_id`) FROM `players` WHERE
`user_id`=".$_SESSION['user_id']);
if ($result3 <= 25) {
fill_team();
} else {
echo 'something else';
}
}
The issue with it is the fact that despite the fact that there are over 25
(by a long way in testing at times) results, it does not stop and echo,
instead it carries on adding more and more. The fill_team() function looks
like so:
function fill_team() {
$i = 1;
while ($i <= 25) {
$first_name = first_name();
$last_name = second_name();
echo "<br>";
$add_names = mysql_query("INSERT INTO `players` (`first_name`,
`last_name`, `user_id`) VALUES ('$first_name', '$last_name',
'{$_SESSION['user_id']}')");
$i++;
}
}
I've tried playing with the numbers but it doesn't seem to make too much
of a difference. I know it's a bit of a unique question but any advice is
greatly appreciated!
No comments:
Post a Comment