Hi,
I have a links page where links are stored in a mysql db. The links are broken up into categories. At the moment I have a seperate query statement and while loop to list all the links from each category. This is messy and increases db queries...
Is there a way that I can make mutiple queries in one statment and then place the results relevent to its category...?
Please advise!
This is the current code... as you can see its just a repeat of each piece of code with a where clause relevent to the category! I suspect this is going to be the only way I can do it...
<?php
// uk sites
$link_id = db_connect("planetdnb");
$query = "select * from links where category='UK SITES' order by link asc";
$result = mysql_query($query);
while($myrow = mysql_fetch_row($result))
{
$site = $myrow[1];
$desc = $myrow[2];
$url = $myrow[3];
echo "<p style='margin-left: 10; margin-top: 0; margin-bottom: 0'><font face=\"arial\" size=\"2\" color='#ffffff'><img src=\"http://www.planetdnb.com/images/page_gfx/link.gif\"><a href=\"$url\" target=\"_blank\">$site</a> - $desc<br></font>";
}
?>
<br>
<center><img src="http://www.planetdnb.com/images/page_gfx/section_titles/europe_sites.gif"><br></center>
<?php
// european sites
$query = "select * from links where category='EUROPEAN SITES' order by link asc";
$result = mysql_query($query);
while($myrow = mysql_fetch_row($result))
{
$site = $myrow[1];
$desc = $myrow[2];
$url = $myrow[3];
echo "<p style='margin-left: 10; margin-top: 0; margin-bottom: 0'><font face=\"arial\" size=\"2\" color='#ffffff'><img src=\"http://www.planetdnb.com/images/page_gfx/link.gif\"><a href=\"$url\" target=\"_blank\">$site</a> - $desc<br></font>";
}
?>
<br>
<center><img src="http://www.planetdnb.com/images/page_gfx/section_titles/world_sites.gif"><br></center>
<?php
// world sites
$query = "select * from links where category='WORLD SITES' order by link asc";
$result = mysql_query($query);
while($myrow = mysql_fetch_row($result))
{
$site = $myrow[1];
$desc = $myrow[2];
$url = $myrow[3];
echo "<p style='margin-left: 10; margin-top: 0; margin-bottom: 0'><font face=\"arial\" size=\"2\" color='#ffffff'><img src=\"http://www.planetdnb.com/images/page_gfx/link.gif\"><a href=\"$url\" target=\"_blank\">$site</a> - $desc<br></font>";
}
?>
<br>
<center><img src="http://www.planetdnb.com/images/page_gfx/section_titles/pirate_sites.gif"><br></center>
<?php
// pirate sites
$query = "select * from links where category='PIRATE/INTERNET RADIO' order by link asc";
$result = mysql_query($query);
while($myrow = mysql_fetch_row($result))
{
$site = $myrow[1];
$desc = $myrow[2];
$url = $myrow[3];
echo "<p style='margin-left: 10; margin-top: 0; margin-bottom: 0'><font face=\"arial\" size=\"2\" color='#ffffff'><img src=\"http://www.planetdnb.com/images/page_gfx/link.gif\"><a href=\"$url\" target=\"_blank\">$site</a> - $desc<br></font>";
}
?>
<br>
<center><img src="http://www.planetdnb.com/images/page_gfx/section_titles/event_sites.gif"><br></center>
<?php
// events
$query = "select * from links where category='EVENT SITES' order by link asc";
$result = mysql_query($query);
while($myrow = mysql_fetch_row($result))
{
$site = $myrow[1];
$desc = $myrow[2];
$url = $myrow[3];
echo "<p style='margin-left: 10; margin-top: 0; margin-bottom: 0'><font face=\"arial\" size=\"2\" color='#ffffff'><img src=\"http://www.planetdnb.com/images/page_gfx/link.gif\"><a href=\"$url\" target=\"_blank\">$site</a> - $desc<br></font>";
}
?>
<br>
<center><img src="http://www.planetdnb.com/images/page_gfx/section_titles/artist_sites.gif"><br></center>
<?php
// artists
$query = "select * from links where category='ARTIST SITES' order by link asc";
$result = mysql_query($query);
while($myrow = mysql_fetch_row($result))
{
$site = $myrow[1];
$desc = $myrow[2];
$url = $myrow[3];
echo "<p style='margin-left: 10; margin-top: 0; margin-bottom: 0'><font face=\"arial\" size=\"2\" color='#ffffff'><img src=\"http://www.planetdnb.com/images/page_gfx/link.gif\"><a href=\"$url\" target=\"_blank\">$site</a> - $desc<br></font>";
}
?>
<br>
<center><img src="http://www.planetdnb.com/images/page_gfx/section_titles/record_labels.gif"><br></center>
<?php
// labels
$query = "select * from links where category='LABEL SITES' order by link asc";
$result = mysql_query($query);
while($myrow = mysql_fetch_row($result))
{
$site = $myrow[1];
$desc = $myrow[2];
$url = $myrow[3];
echo "<p style='margin-left: 10; margin-top: 0; margin-bottom: 0'><font face=\"arial\" size=\"2\" color='#ffffff'><img src=\"http://www.planetdnb.com/images/page_gfx/link.gif\"><a href=\"$url\" target=\"_blank\">$site</a> - $desc<br></font>";
}
?>
<br>
<center><img src="http://www.planetdnb.com/images/page_gfx/section_titles/record_shops.gif"><br></center>
<?php
// shops
$query = "select * from links where category='ONLINE SHOPS' order by link asc";
$result = mysql_query($query);
while($myrow = mysql_fetch_row($result))
{
$site = $myrow[1];
$desc = $myrow[2];
$url = $myrow[3];
echo "<p style='margin-left: 10; margin-top: 0; margin-bottom: 0'><font face=\"arial\" size=\"2\" color='#ffffff'><img src=\"http://www.planetdnb.com/images/page_gfx/link.gif\"><a href=\"$url\" target=\"_blank\">$site</a> - $desc<br></font>";
}
?>
<br>
<center><img src="http://www.planetdnb.com/images/page_gfx/section_titles/various_sites.gif"><br></center>
<?php
// various
$query = "select * from links where category='VARIOUS SITES' order by link asc";
$result = mysql_query($query);
while($myrow = mysql_fetch_row($result))
{
$site = $myrow[1];
$desc = $myrow[2];
$url = $myrow[3];
echo "<p style='margin-left: 10; margin-top: 0; margin-bottom: 0'><font face=\"arial\" size=\"2\" color='#ffffff'><img src=\"http://www.planetdnb.com/images/page_gfx/link.gif\"><a href=\"$url\" target=\"_blank\">$site</a> - $desc<br></font>";
}