Jump to content

Getting Custom Data from Database


Recommended Posts

I'm trying to connect to the database to retrieve information from a specific MySQL table. My code is in a .tpl file that's associated with the Smarty template system.

 

Here's a copy of my code:

 

{php}
$result = mysql_query("SELECT * FROM tbldownloads");
while($row = mysql_fetch_assoc($result))
{
   $customdata[] = $row;    
}
$ca->assign('customdata', $customdata);  
{/php}

	<section>
		<table id="downloads" class="table table-striped table-bordered" cellspacing="0" width="100%">
			<thead><tr><th>Name</th><th style="text-align:center;">Developer</th><th style="text-align:center;">Version</th><th style="text-align:center;">Download</th></tr></thead>
			<tfoot><tr><th>Name</th><th style="text-align:center;">Developer</th><th style="text-align:center;">Version</th><th style="text-align:center;">Download</th></tr></tfoot>
			<tbody>
				{foreach from=$customdata item=customdata}
					<tr>
						<td>{$customdata.title}</td>
						<td style="text-align:center;">{$customdata.downloads}</td>
						<td style="text-align:center;">{$customdata.description}</td>
						<td style="text-align:center;"><a href="dl.php?type=d&id={$customdata.id}" class="btn btn-primary">DOWNLOAD</a></td>
					</tr>
				{/foreach}
			</tbody>
		</table>
	</section>

 

 

This is the error I'm getting:

 

Fatal error: Call to a member function assign() on a non-object in /home/lximcvez/templates_c/%%B2^B21^B2190A74%%access.tpl.php on line 62

 

Line 62 of the outputted PHP file contains this: $ca->assign('customdata', $customdata);

 

I'm not really sure why I'd be getting this error or what I need to change Any help would be appreciated.

Edited by EscalateSEO
Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated