Jump to content

[SOLVED] Help With Smarty Code


steviez

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.