writing mysql data to multiple files on a web site with php
Posted: Fri Mar 07, 2008 9:48 am
I'm using the following php code to populate a web page with hyperlinks via a mysql db:
/* <?php
$con = mysql_connect("localhost","uid","pw");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("mydb", $con);
$result = mysql_query("SELECT link
FROM tbllinkcat, tbllinks
WHERE tbllinkcat.catid = tbllinks.catid
AND tbllinkcat.catid=1;");
while($row = mysql_fetch_array($result))
{
echo "<ul>";
echo "<li>" . $row['link'] . "</li>";
echo "</ul>";
}
mysql_close($con);
?>
*/
Although the above code works fine when embedded in one web page, it is not a very efficient way of using mysql/php. What I REALLY want to do is populate ALL my web site web pages with links stored in mysql. I've done this with Dreamweaver/MySQL/IIS but I would really like figure this out using Apache/MySQL/PHP. I've tried googling and searched the mysql and php docs, but I've come up empty so far. If someone could kindly point me in the right direction (url, or code example) it would be greatly appreciated. Thanks!
/* <?php
$con = mysql_connect("localhost","uid","pw");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("mydb", $con);
$result = mysql_query("SELECT link
FROM tbllinkcat, tbllinks
WHERE tbllinkcat.catid = tbllinks.catid
AND tbllinkcat.catid=1;");
while($row = mysql_fetch_array($result))
{
echo "<ul>";
echo "<li>" . $row['link'] . "</li>";
echo "</ul>";
}
mysql_close($con);
?>
*/
Although the above code works fine when embedded in one web page, it is not a very efficient way of using mysql/php. What I REALLY want to do is populate ALL my web site web pages with links stored in mysql. I've done this with Dreamweaver/MySQL/IIS but I would really like figure this out using Apache/MySQL/PHP. I've tried googling and searched the mysql and php docs, but I've come up empty so far. If someone could kindly point me in the right direction (url, or code example) it would be greatly appreciated. Thanks!