| MYSQL with PHP help : Urgent
|
nani nisha06

msg:4494241 | 11:17 am on Sep 12, 2012 (gmt 0) | Hi Friends, I am back with another question on the webmasterworld. I am working on a project where i need to created a ticketing information with multiple attributes. of course MYSQL database is ready but now I need the data to be projected on a template which is powered by HTML code but, I want to fetch this data using PHP & MYSQL Command.....As a sample I have created a DB as below namefav_colorfav_foodpet RosePink Tacos Cat BradleyBlue PotatoesFrog MarieBlack PopcornDog AnnOrange Soup Cat $data = mysql_query("SELECT * FROM $tbl_name") or die(mysql_error()); Print "<table border cellpadding=3>"; while($info = mysql_fetch_array( $data )) { Print "<tr>"; Print "<th>name:</th> <td>".$info['name'] . "</td> "; Print "<th>pet:</th> <td>".$info['pet:'] . " </td></tr>"; } Print "</table>"; ?> But when I use the above code on the data to read using PHP I get results as below: Name:RosePet:Cat Name: Bradleypet:Frog Name:Mariepet:Dog Name:Annpet:Cat But I want it to project the data on the template as is of first table On the point 2: I want only 3o rows to be displayed in each page so, I need a code to auto generate multiple pages for this data. Thanks in advance! Regards, Naveen
|
eelixduppy

msg:4494288 | 1:17 pm on Sep 12, 2012 (gmt 0) | You are looping on too much. Try just the following:
echo '<table><tr><td>Name</td><td>Pet</td></tr>'; while($info = myself_fetch_array($data)) { echo "<tr><td>{$info['name']}</td><td>{$info['pet']}</td></tr>"; } echo '</table>';
Also, you are looking for pagination. Here's my go-to thread, but you should be able to find many examples of this online as well: [webmasterworld.com...]
|
nani nisha06

msg:4496139 | 7:26 am on Sep 17, 2012 (gmt 0) | Hi EElixduppy, Thanks this is solved now but I need some help on applying filters. Regards, Naveen
|
|
|