How to generate xml from a php image gallery

7331

New Member
I am sort of new to php and totally new to ajax, so im still learning. The function below is what I currently have, it queries the database and outputs the images for my website. This works fine. I am now trying to generate xml from the results to feed into javascript so that if the user wants to have a different view of the gallery - (2 rows instead of 4 for example), the page just updates without refreshing. Would I have to assign all the results to an array and then extract it with javascript ? Not sure where to even start. Please point me in a direction, many thanks !\[code\]<?php include 'library/connect.php';$result = mysql_query("SELECT * FROM fproduct WHERE fproduct.category='Shirts'");$cols=3;echo "<table>";do{ echo "<tr>"; // adds a new row after the for loop has been executed for 4 times (4 columns) for($i=1;$i<=$cols;$i++){ $row=mysql_fetch_array($result); if ($row) {?> <td> <a href = "http://stackoverflow.com/questions/15737728/Shirtbuy.php?id=<? echo $row['product_id'] ?>" ><img border="0" alt="pic" src="http://stackoverflow.com/questions/15737728/images/products/shirts/largethumbs/<? echo $row['pic']?>" /></a> <br/> <b><?= $row['prod_name']?> </b><br/> <b><?= $row['price']?> </b><br/> </td> <td width="100">&nbsp;</td> <? } else{ echo "<td>&nbsp;</td>"; //If there are no more records at the end, add a blank column } } } while($row); echo "</table>";include 'library/close.php';\[/code\]
 
Back
Top