show.php and one is show.tpl.

Reply

Join Date: Oct 2006
Posts: 75
Reputation: welbyobeng is an unknown quantity at this point 
Solved Threads: 0
welbyobeng welbyobeng is offline Offline
Junior Poster in Training

show.php and one is show.tpl.

 
0
  #1
Aug 14th, 2008
I have two file one called show.php and one is show.tpl.

On show.php it has this code

//-----------------------------------------
// Fetch Media
//-----------------------------------------
$db->query("SELECT files.*, categories.*, users.id, users.username FROM categories, files LEFT JOIN users ON files.mid=users.id WHERE $search_addon files.category_id=categories.category_id AND files.type != 'plug' AND $v $ss ORDER BY files.featured DESC, files.$sort LIMIT $set_limit, $per_page");
$lists = $db->fetch_rows();
$media_num = $db->get_num_rows();
On show.tpl it has this code

<table align="center" border="0" cellpadding="4" cellspacing="1" class="admin_table">
<tr class="main_row_color">
<td style='width:1%;'><a href="{$siteurl}/admin.php?view=admin_media&sort=file_id"><b>ID</b></a></td>
<td style='width:30%;' colspan="2"><a href="{$siteurl}/admin.php?view=admin_media&sort=title"><b>Title</b></a></td>
<td style='width:20%;'><a href="{$siteurl}/admin.php?view=admin_media&sort=category_id"><b>Category</b></a></td>
<td style='width:15%;'><a href="{$siteurl}/admin.php?view=admin_media&sort=mid"><b>Uploader</b></a></td>
<td style='width:10%;'><b>Options</b></td>
<td style='width:1%;'><b>Select</b></td>
</tr>

Together when loaded it shows the table below

ID Title Category Uploader Options Select

My question is how can I get it to show artist from "files" table in my database for it to show what I want below?


ID Title Artist Category Uploader Options Select
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 100
Reputation: petr.pavel is an unknown quantity at this point 
Solved Threads: 14
petr.pavel's Avatar
petr.pavel petr.pavel is offline Offline
Junior Poster

Re: show.php and one is show.tpl.

 
0
  #2
Sep 18th, 2008
Hi Welbzobeng,
have a look at the query. After SELECT and before FROM it lists what attributes it will fetch for you. files.* means "all attributes from table files so your artist should be covered.
You didn't say what attributes your db table "files" has so I can only assume that artist name is one of them. Let's assume it's called "artist".

You only showed us a part of show.tpl that displays table headings. Adding a new heading for Artist is easy, just insert this:
  1. <td><a href="{$siteurl}/admin.php?view=admin_media&sort=artist"><b>Artist</b></a></td>
This piece of code also adds the link for sorting. I hope that somewhere in show.php you secure values in $sort because if not you're risking a SQL injection attack.

You didn't provide PHP code that assigns result of the query to your template (if you're using Smarty then it's something like $smarty->assign('variable', $values); ) and you didn't give us the part of your template that actually shows it. You will have to edit the template part and maybe the PHP part as well.
Post them here if you need more help.

Also I wouldn't be surprised if you had a separate db table for artists and "files" only used artist.id as a foreign key. Give us more details on your db tables if you need assistance here.
Petr 'PePa' Pavel

The more information you give the more relevant answer you get.
Please consider using "Add to ... Reputation" and mark your thread as Solved if you found what you were looking for. By giving feedback you help others.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC