| | |
how to cover while loop in php template
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2008
Posts: 74
Reputation:
Solved Threads: 0
i am working on creating php templates for an application, but i am not understanding how to cover while loop in templates, my code is as follow, that is not right and of course not working at all, it is being posted just for example. Please any body give me an idea that how it can be implemented,
the temp-test.php file as follow
any suggestion please, thanks in advance....
<?php
require_once("temp-test.php");
mysql_connect("localhost", "root","")or die("cannot connect");
mysql_select_db("test") or die("cannot select DB");
$sql="SELECT rid,tid,name FROM reply";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$rid=$row[rid];
$tid=$row[tid];
$name=$row[name];
}
?><html> <head> <title>template</title> </head> <body> <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="360" height="100"> <tr><td width="358" height="100"> <p style="margin-left: 10; margin-top: 0; margin-bottom: 5"><font face="Segoe UI">Reply ID:<font color="#DA251D"> <?php echo "$rid";?></font></font></p> <p style="margin-left: 10; margin-top: 0; margin-bottom: 5"><font face="Segoe UI">Topic ID:<font color="#DA251D"><?php echo "$tid";?></font></font></p> <p style="margin-left: 10; margin-top: 0; margin-bottom: 5"><font face="Segoe UI">Name: <font color="#DA251D"><?php echo "$name";?> </font></font></p></td></tr></table><br> </body> </html>
any suggestion please, thanks in advance....
Do you have to design your own templating system ? Otherwise, have a look at Smarty. It will cover all your templating needs.
If you need to create your own, then you would have to define a begin and end marker in your template, and program the parser to copy everything in between and replace your row values. (like XTemplate handles it)
If you need to create your own, then you would have to define a begin and end marker in your template, and program the parser to copy everything in between and replace your row values. (like XTemplate handles it)
![]() |
Other Threads in the PHP Forum
- Previous Thread: Google Maps help needed.
- Next Thread: PHP data retrieval from SQL problem
| Thread Tools | Search this Thread |
apache api array basic beginner binary broken cache cakephp checkbox class cms code computing confirm cron curl customizableitems database date delete display dynamic echo email error external file files filter folder form forms forum function functions gc_maxlifetime google headmethod host howtowriteathesis href htaccess html iframe image include insert ip javascript joomla limit link login mail malfunction memmory memory menu mlm multiple mysql navigation oop parsing paypal pdf php phpmysql problem query question radio random recursion remote script search select server sessions sms snippet source space sql syntax system table thesishelp trouble tutorial update upload url validator variable video web youtube





