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?
sending database of links to html
Moderator: General Moderators
-
jaymoore_299
- Forum Contributor
- Posts: 128
- Joined: Wed May 11, 2005 6:40 pm
- Contact:
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
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
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
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