How get multiple values from first mysql table and use it in second query?
table1
id | author | number_of_view |
---+--------------+-----------------
1 | john | 10
2 | Jack | 20
3 | Anna | 80
4 | Neri | 100
Below I have php script which checks MySQL database table and gives badge
to users. The script works prefectly.
$from1=10;
$to1=15;
$from2=20;
$to2=30;
$query=mysql_query("SELECT SUM( number_of_view ) AS view_number, author
FROM `table1` GROUP BY author");
while ($row= mysql_fetch_array($query))
{
$view_number=$row['view_number'];
$author=$row['author'];
if ($viewnumber>$from1 && $viewnumber<=$to1)
{
echo "special user";
}
elseif ($viewnumber>$from2 && $viewnumber<=$to2)
{
echo "plain user";
}
}
}
But problem is that I want to get $from and $to variable values from
database table:
table2
id | badge | from |to
---+-------------+------+---
1 | special user| 10 |15
2 | plain user | 20 |30
How can I do that? Thank you in advance for your help.
No comments:
Post a Comment