steviez Posted December 28, 2007 Share Posted December 28, 2007 Hi, I am using smarty to design my site and need to convert this code so i can use it in a smarty template: $result = mysql_query("SELECT * FROM uploads where uploader = 'steviez'"); while($row = mysql_fetch_array($result)){ echo '<tr class="sub_table highlight">'; echo '<td></td>'; echo '<td>'.$row['name'].'</td>'; echo '<td>1 (MB)</td>'; echo '<td><a href="#" target="_blank">Click here</a></td>'; echo '<td><a href="#">Click Here</a></td>'; echo '<td><a href="#">Remove</a> <a href="#">Add</a></td>'; echo '</tr>'; } } any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/83458-solved-help-with-smarty-code/ Share on other sites More sharing options...
Daniel0 Posted December 28, 2007 Share Posted December 28, 2007 PHP code: <?php // ... $result = mysql_query("SELECT * FROM uploads where uploader = 'steviez'"); $uploads = array(); while($row = mysql_fetch_array($result)) { $uploads[] = $row; } // we'll assume that the smarty object is called $smarty $smarty->assign('uploads', $uploads); // ... ?> Smarty template code: {section name=upload loop=$uploads} <tr class="sub_table highlight"> <td></td> <td>{$uploads[upload].name}</td> <td>1 (MB)</td> <td><a href="#" target="_blank">Click here</a></td> <td><a href="#">Click Here</a></td> <td><a href="#">Remove</a> <a href="#">Add</a></td> </tr> {/section} Look, I have never touched Smarty before, yet I was able to create this in no time. Reading the Smarty manual might be a good idea. Quote Link to comment https://forums.phpfreaks.com/topic/83458-solved-help-with-smarty-code/#findComment-424677 Share on other sites More sharing options...
steviez Posted December 28, 2007 Author Share Posted December 28, 2007 I have, but when you dont know what your looking for its a bit hard! Thanks anyway Quote Link to comment https://forums.phpfreaks.com/topic/83458-solved-help-with-smarty-code/#findComment-424733 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.