Page 1 of 1

sending database of links to html

Posted: Wed Jun 01, 2005 11:31 am
by jaymoore_299
What is the best way to send a database of links in mysql database:
url1 , url_text1
url2 , url_text2
url3 , url_text3
...

so that they are saved in a html page like this.
<a href="url1">url_text1</a><br>
<a href="url2">url_text2</a><br>
<a href="url3">url_text3</a><br>

so that when I go to edit that page, I actually see the formatted code and not an include(..

Is there a way for php to output to a file rather than to the browser so that the file itself has no include, but has the actual desired code in it?

Posted: Wed Jun 01, 2005 12:00 pm
by shiznatix
do you really want to save them as a seperate html file and not just display them as html with php? ill show you both

Code: Select all

$query = '
    SELECT
        url, url_text
    FROM
        url_table
';

$do_query = mysql_query($query) or die(mysql_error().__LINE__);

while ($info = mysql_fetch_assoc($do_query))
{
    echo '<a href="'.$info[url].'">'.$info[url_text].'</a><br>';
}
//that one will echo out the results as links, thats the prefered method
but if you want to just write to a html file just use fopen, fwrite, fread, fclose OR (these 2 are easier -->) file_get_contents, file_put_contents