Page 1 of 1

php code to save to multiple html from qurery string

Posted: Wed Apr 23, 2008 5:03 am
by yoru_san
i want to save separate page of html file as name.html
how to set lop command? or change fetcharr to fetsharr_row ?

<?php

$name = $fetcharr['idol_name'];
$address = $fetcharr['address_i'];
$star = $fetcharr['rating'];

//generate HTML for the idol page

$html="
<head><title>Quizzy.net - Quizzes and Personality
Tests</title>\n
<link rel=stylesheet
href=".SITE_URL."templates/ styles.css></head>\n
<table align=center width=600>\n
<tr><td><b>$name</b></a><br><b>Address</b>$address<img src=\"$star.gif\"/> </td></tr> \n";

//generate file name
$fname=str_replace(" ","-",$name);


//open file
$fp=fopen("$fname.html","wb");
fwrite($fp,$html);
fclose($fp);

?>

thank you :D

Re: php code to save to multiple html from qurery string

Posted: Wed Apr 23, 2008 5:33 am
by onion2k
Besides the fact you're writing the file as binary ("wb" in fopen() ) instead of text ("w" in fopen() ), I can't really see anything wrong with your code. What's the problem exactly?

Re: php code to save to multiple html from qurery string

Posted: Wed Apr 23, 2008 9:24 am
by yoru_san
i have data in 200-300 rows in mysql
and want to parsing all field in static html page separate by 1 row per 1 page
so i don't know how to make looping command to produce these html files.

thank you for your reply :D