jj20051 Posted August 9, 2010 Share Posted August 9, 2010 Ok... So I have a while() query to pull support tickets from my database. I would like to setup a system where the while() function is called inside a template file, without having the template file contain the lines of code for it. Example While Function: $open_tickets = mysql_query("SELECT * FROM support_tickets WHERE user_id='$id' && order_by='1' && ticket_status='open' ORDER BY ticket_id DESC") or die(mysql_error()); while($tick = mysql_fetch_array($open_tickets, MYSQL_ASSOC)) { ?> <tr><td><a href="tickets.php?id=<?php echo $tick['ticket_id'].'">'.$tick['ticket_title']; ?></a></td><td><div align="center"><?php echo $tick['ticket_reply']; ?></div></td><td><div align="center"><?php echo $tick['ticket_urgency']; ?></div></td></tr> <?php } It would be awesome if I could get all that to run off of looping variables so that the template looks like: <?php $begin_while; ?> <tr><td><a href="tickets.php?id=<?php echo $ticket_id; ?>"><?php echo $ticket_title; ?></a></td><td><div align="center"><?php echo $ticket_reply; ?></div></td><td><div align="center"><?php echo $ticket_urgency; ?></div></td></tr> <?php $end_while; ?> or something similar. Suggestions? I don't want to implement smarty or another template system, at least not yet... I just want something in php that can do what's described above. Of course all I'm really looking for is something that looks cleaner... Could I make the while function $tick into something smaller and place the query into the system instead of the template? Link to comment https://forums.phpfreaks.com/topic/210214-php-while-template-engine/ Share on other sites More sharing options...
jj20051 Posted August 9, 2010 Author Share Posted August 9, 2010 Ok I figured it out in a flash of genius, sorry if I bugged anyone. Link to comment https://forums.phpfreaks.com/topic/210214-php-while-template-engine/#findComment-1096992 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.