how to cover while loop in php template

Reply

Join Date: May 2008
Posts: 74
Reputation: servis is an unknown quantity at this point 
Solved Threads: 0
servis servis is offline Offline
Junior Poster in Training

how to cover while loop in php template

 
0
  #1
May 28th, 2008
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,

<?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];
}
?>
the temp-test.php file as follow
<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....
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 831
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 136
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Practically a Posting Shark

Re: how to cover while loop in php template

 
0
  #2
May 28th, 2008
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)
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 74
Reputation: servis is an unknown quantity at this point 
Solved Threads: 0
servis servis is offline Offline
Junior Poster in Training

Re: how to cover while loop in php template

 
0
  #3
May 28th, 2008
yes i want to create my own template but i don't know how it can be done, please if you can quote me an example...however thank you very much for idea....
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC