943,632 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 607
  • PHP RSS
Aug 14th, 2008
0

show.php and one is show.tpl.

Expand Post »
I have two file one called show.php and one is show.tpl.

On show.php it has this code

Quote ...
//-----------------------------------------
// 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

Quote ...
<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
Similar Threads
Reputation Points: 13
Solved Threads: 0
Junior Poster in Training
welbyobeng is offline Offline
75 posts
since Oct 2006
Sep 18th, 2008
0

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

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:
html Syntax (Toggle Plain Text)
  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.
Reputation Points: 27
Solved Threads: 16
Junior Poster
petr.pavel is offline Offline
116 posts
since Mar 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: PHP: reporting upload progress
Next Thread in PHP Forum Timeline: how to update database on the basis of real tme entry





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC