01-15-2008, 05:36 PM
|
#14 (permalink)
|
|
The Frequenter
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
|
The new problem is because your second query only fetches 1 row.
I've adjusted your code so that it should read multiple rows using the SQL IN() function.
PHP Code:
$web = "SELECT tuto_id,rate FROM rate ORDER BY rate DESC LIMIT 2";
$tuto = mysql_query($web) or die('Database error: ' . mysql_error());
// Loop through the query results...
while ($mas = mysql_fetch_array($tuto))
{
// ...and put each tuto_id into a new array...
$inClause_a[] = $mas['tuto_id'];
}
// ...which we then turn into a comma seperated string by using implode()
$inClause = implode(',', $inClause_a);
$web2="select * from tuto where id IN($inClause)'";
$res2=mysql_query($web2);
while($mas2 = mysql_fetch_array($res2))
{
echo "<tr><td>Most 4 best rated tutorials</tr><tr><td>".$mas2['title']."</tr>";
}
I haven't tested the code but it should work.
Alan
|
|
|