Noob - a simple way to turn mysql results into variables?
Posted: Tue Jun 10, 2003 1:41 pm
HI!
I'm trying to write a php page that formats MySQL results as XML - making all the files and stuff is quite straightforward but i need a way of chopping my $result array up into variables - the problem is that there will be 4 table rows in each $result, so there will be 4 PageNum and 4 PageID etc each time - how do i assign them to separate named variables?
Any help would be very gratefully received!!
thanks
here's the relevant bit of code
I'm trying to write a php page that formats MySQL results as XML - making all the files and stuff is quite straightforward but i need a way of chopping my $result array up into variables - the problem is that there will be 4 table rows in each $result, so there will be 4 PageNum and 4 PageID etc each time - how do i assign them to separate named variables?
Any help would be very gratefully received!!
thanks
here's the relevant bit of code
Code: Select all
<?php
$req = mysql_query("SELECT PageNum,PageID,PagePathName FROM schoolmasterpages WHERE LessonID='$L' ");
while ($L<=10){
touch("D:\Program Files\xmlFiles\lesson".$L.".xml");
$fp = fopen("D:\Program Files\xmlFiles\lesson".$L.".xml", "w") or die ("no go");
fwrite($fp, "<?xml version="1.0" standalone="yes"?>\n");
fwrite($fp, "<games>\n");
$i=0;
while ($result = mysql_fetch_array($req))
{
echo $result[PagePathName]."<br>";
$i++;
}
?>