I didnt get anything out of that!
Let me try to explain what I have done so far and what I have experinced!
First I have these records in my DB table:
(uid, imagenumber, image)
- 2, 3, test3.jpg
- 4, 1, test1.jpg
- 2, 1, test1.jpg
My PHP looks like this:
Code: Select all
if ( !$this->CheckPermission('Use Sponsor Manager') )
{
$this->_DisplayErrorPage($id, $params, $returnid,
$this->Lang('accessdenied'));
return;
}
$db =& $this->GetDb();
$this->smarty->assign ('title', $this->Lang ('editsponsor'));
if (!isset ($params['uid']))
{
$this->smarty->assign ('message', $this->Lang ('error_nosponsor'));
$this->smarty->assign ('error', 1);
return;
}
$query = "SELECT * FROM ".cms_db_prefix ()."module_sponsormanager_users WHERE uid = ?";
$dbresult = $db->Execute ($query, array($params['uid']));
$course = $dbresult->FetchRow ();
$smarty->assign ('user', $course['user_name']);
$query =
"SELECT * FROM ".cms_db_prefix ().
"module_sponsormanager_sponsor WHERE uid = ?";
$dbresult = $db->Execute ($query, array($params['uid']));
if (!$dbresult)
{
$this->smarty->assign ('message', $this->Lang ('error_dberror'));
$this->smarty->assign ('error', 1);
echo $this->ProcessTemplate ('sponsor.tpl');
return;
}
$row = $dbresult->FetchRow ();
if (!$row)
{
$this->smarty->assign ('message', $this->Lang ('error_dberror'));
$this->smarty->assign ('error', 1);
echo $this->ProcessTemplate ('sponsor.tpl');
return;
}
$smarty->assign ('image', $row['image']);
$smarty->assign ('imagenumber', $row['imagenumber']);
echo $this->ProcessTemplate ('sponsor.tpl');
And my template looks like this:
Code: Select all
<p style="font-size:12px; font-weight:bold">{$title} - {$club}</p> <br>
{if $message != ''}
{if $error != ''}
<p><font color="red">{$message}</font></p>
{else}
<p>{$message}</p>
{/if}
{else}
<table width="450" border="0" cellspacing="2" cellpadding="0">
<tr>
<td>{if $imagenumber == '1'}
<table width="200" border="0" cellspacing="0" cellpadding="2">
<tr><td>1</td></tr>
<tr><td height="50"><img src="../uploads/{$image}" width="150" height="50" /></td></tr>
</table>
{else}
<table width="200" border="0" cellspacing="0" cellpadding="2">
<tr><td>1</td></tr>
<tr><td height="50">No image!</td></tr>
</table>
{/if}</td>
<td>{if $imagenumber == '2'}
<table width="200" border="0" cellspacing="0" cellpadding="2">
<tr><td>2</td></tr>
<tr><td height="50"><img src="../uploads/{$image}" width="150" height="50" /></td></tr>
</table>
{else}
<table width="200" border="0" cellspacing="0" cellpadding="2">
<tr><td>2</td></tr>
<tr><td height="50">No image!</td></tr>
</table>
{/if}</td>
<td>{if $imagenumber == '3'}
<table width="200" border="0" cellspacing="0" cellpadding="2">
<tr><td>3</td></tr>
<tr><td height="50"><img src="../uploads/{$image}" width="150" height="50" /></td></tr>
</table>
{else}
<table width="200" border="0" cellspacing="0" cellpadding="2">
<tr><td>3</td></tr>
<tr><td height="50">No image!</td></tr>
</table>
{/if}</td>
</tr>
</table>
{/if}
As you can see I want to be able to look through the db table and find imagenumber 1,2,3 for a certain uid, and if the image doesnt exist then go to else... In this case my uid = 2. It finds without any problems the first record in my db table with the imagenumber = 3 but then it stops looking... It doesnt find imagenumber = 1

It seems like it stops looking after first record... What am I doing wrong?