I was wondering if it's possible to combine them in one while loop, using a variable for the changing word.
Here are my 4 queries
Code: Select all
$query = mysql_query("SELECT id, topicname, description FROM forumtopics WHERE cat = 'general' ORDER BY rank");
while($array = mysql_fetch_array($query))
{
// code
}
$query = mysql_query("SELECT id, topicname, description FROM forumtopics WHERE cat = 'people' ORDER BY rank");
while($array = mysql_fetch_array($query))
{
// code
}
$query = mysql_query("SELECT id, topicname, description FROM forumtopics WHERE cat = 'subject' ORDER BY rank");
while($array = mysql_fetch_array($query))
{
// code
}
$query = mysql_query("SELECT id, topicname, description FROM forumtopics WHERE cat = 'site' ORDER BY rank");
while($array = mysql_fetch_array($query))
{
// code
}What I would like is something like this
Code: Select all
$query = mysql_query("SELECT id, topicname, description FROM forumtopics WHERE cat = '$variable' ORDER BY rank");Grr, hope I explained myself okay.
Just to summarize
4 separate queries here
need to loop through them, with the query changing each time it goes through.