Return to iWEBTOOL

Go Back   iWEBTOOL Talk > The Web and your Website > Programming > PHP
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
Welcome to iWEBTOOL Talk, where you talk about webmaster-related stuff.
 
Discuss topics which interest you.
With over thousands of threads (topics), we're sure you'll find something that'll interest you.
Ask for help whenever you need it.
We have thousands of members who are available to help you if you need it.
It's absolutely FREE!

 1  Register           2  Browse the board           3  Discuss whatever may interest you!
 


Closed Thread
 
Thread Tools Search this Thread Display Modes
Old 04-18-2007, 03:37 AM   #1
doodnom
Junior Member
 
doodnom's Avatar
 
Join Date: Sep 2006
Posts: 18
doodnom will become famous soon enough
Default Create HTML file from Mysql Result

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);
?>
__________________
Spain Hotels
asian cooking
doodnom is offline  
 
This is an Ad Revenue Sharing forum Place your advert here
SEO Checklist
Get yourself better ranking with
our "Do-it-Yourself" SEO Checklist.
Click Here
Old 05-06-2007, 03:25 PM   #2
pelinga
Member
 
pelinga's Avatar
 
Join Date: May 2007
Posts: 125
pelinga is on a distinguished road
Default Re: Create HTML file from Mysql Result

you can use
$lines = file('http://www.example.com/');
see more at
http://www.php.net/file
pelinga is offline  
Old 05-06-2007, 03:31 PM   #3
jumpenjuhosaphat
 Contributor 
 
jumpenjuhosaphat's Avatar
 
Join Date: Jun 2006
Location: Denver
Posts: 4,459
jumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud of
Default Re: Create HTML file from Mysql Result

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?
__________________
Storage Sheds
Lost Forum
jumpenjuhosaphat is offline  
Old 05-15-2007, 08:47 PM   #4
_torero_
Junior Member
 
_torero_'s Avatar
 
Join Date: Mar 2007
Posts: 99
_torero_ will become famous soon enough
Default Re: Create HTML file from Mysql Result

can somebody BAN this spammer is like the 3rd time he posts the same

Quote:
Originally Posted by imagine View Post
We have tons of scripts for sale. We have the following script packages below and also you may purchase scripts individually. Please send all emails to bestscriptz@yahoo.com.

Below are our individual scripts and also we have the packages below at the bottom. To see our demos send an email to bestscriptz@yahoo.com. All prices are negotiable.


1. Myspace Scripts
2. Myspace Support & Generator
3. Alibaba/B2B.com
4. HotorNot
5. Myspace Train
6. Web host billing & support
7. Job Script
8. Dating Script
9. Scriptlance Script
10. Freelance Script
11. Community Script
12. Classified Script
13. Auto Classified Script
14. Business Verification
15. Escrow
16. Homebased Business
17. Milliondollarhomepage Script
18. Facebook Script
19. Youtube Script
20. Ringtone
21. Auction Script
__________________
Free Link Exchange - Los Optimizadores - Posicionamiento Web
diseņo Web - Web Design Templates
_torero_ is offline  
Old 05-15-2007, 08:51 PM   #5
_torero_
Junior Member
 
_torero_'s Avatar
 
Join Date: Mar 2007
Posts: 99
_torero_ will become famous soon enough
Default Re: Create HTML file from Mysql Result

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
_torero_ is offline  
Old 05-23-2007, 06:36 PM   #6
4e4en
Newcomer
 
4e4en's Avatar
 
Join Date: May 2007
Location: 4Dev.NeT
Posts: 26
4e4en is on a distinguished road
Send a message via Skype™ to 4e4en
Default Re: Create HTML file from Mysql Result

i dont understand anything

you can try to $rows=explode($str,"\r\n");
4e4en is offline  
 
This is an Ad Revenue Sharing forum Place your advert here
Webmaster Tools Webmaster Tools Click Here
Closed Thread

(Threads which have no activity for more than 30 days are automatically closed.)



Quick Reply
Message:

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Forum Jump

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


All times are GMT. The time now is 10:01 PM.


Powered by vBulletin v3.6.7 © 2008, Jelsoft Enterprises Ltd. SEO by vBSEO © 2006, Crawlability, Inc.