|
| |||||||
![]() | Welcome to iWEBTOOL Talk, where you talk about
webmaster-related stuff.
1 Register
2 Browse the board
3 Discuss whatever may interest you! | |||||||||||||
![]() |
| | Thread Tools | Search this Thread | Display Modes |
| | #1 |
| Junior Member Join Date: Sep 2006
Posts: 18
![]() | Hi Guys, Please find PHP code below, I want to create HTML file from Mysql result one row to one HTML file ( below only display ), anyone please recommend how can i do Thank you <?php $mysql_host = 'localhost'; $mysql_user='root'; $mysql_password=; $mysql_db='account'; if (!$link = mysql_connect($mysql_host,$mysql_user,$mysql_passw ord)) { echo 'Could not connect to mysql'; exit; } if (!mysql_select_db($mysql_db, $link)) { echo 'Could not select database'; exit; } $sql = 'SELECT * FROM account WHERE id = 1001'; $result = mysql_query($sql, $link); if (!$result) { echo "DB Error, could not query the database\n"; echo 'MySQL Error: ' . mysql_error(); exit; } while ($row = mysql_fetch_assoc($result)) { echo $row['id']; echo "<br>"; echo $row['category']; echo "<br>"; echo $row['employ']; echo "<br>"; echo "<b>".$row['title']."</b"; echo "<br>"; echo $row['keywords']; echo "<br>"; echo $row['account']; } mysql_free_result($result); ?> |
| |
|
| |||||||
| | #2 |
| Member Join Date: May 2007
Posts: 125
![]() |
__________________ |
| |
| | #3 |
| Contributor Join Date: Jun 2006 Location: Denver
Posts: 4,459
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Do you mean that you want to write an HTML file base off of the results of a MySQL query? As in writing a physical file called example.html? |
| |
| | #4 | |
| Junior Member Join Date: Mar 2007
Posts: 99
![]() | can somebody BAN this spammer is like the 3rd time he posts the same Quote:
__________________ Free Link Exchange - Los Optimizadores - Posicionamiento Web diseņo Web - Web Design Templates | |
| |
| | #5 |
| Junior Member Join Date: Mar 2007
Posts: 99
![]() | yes you can just write plain HTML or whatever you like into any file in the system so long you have write priviledges. you can just use fwrite, or even a temp file for temporary storage. Once you have your strings ready, just use: <?php $filename = 'test.txt'; $somecontent = "Add this to the file\n"; // Let's make sure the file exists and is writable first. if (is_writable($filename)) { // In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!$handle = fopen($filename, 'a')) { echo "Cannot open file ($filename)"; exit; } // Write $somecontent to our opened file. if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; } echo "Success, wrote ($somecontent) to file ($filename)"; fclose($handle); } else { echo "The file $filename is not writable"; } ?> cheers
__________________ Free Link Exchange - Los Optimizadores - Posicionamiento Web diseņo Web - Web Design Templates |
| |
| | #6 |
| Newcomer | i dont understand anything ![]() you can try to $rows=explode($str,"\r\n"); |
| |
(Threads which have no activity for more than 30 days are automatically closed.) |
| Quick Reply | ||
|
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Expload Upload - Free file hosting + File SHARING Website | hemanthjava | Websites for Sale | 0 | 02-25-2007 09:09 AM |
| Free File Hosting + File Sharing Website | hemanthjava | Websites for Sale | 0 | 02-25-2007 09:08 AM |
| Create Magazine Announces The 2007 Create Awards | inovartis | Advertise your website | 1 | 02-11-2007 09:43 PM |
| Need to create HTML sitemap | vijaygupta88 | Programming | 8 | 01-30-2007 12:51 PM |
| how to create a file for rss | terryjohn.smith | Search Engine Optimization (SEO) | 3 | 09-23-2006 10:22 AM |