| | |
show.php and one is show.tpl.
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2006
Posts: 75
Reputation:
Solved Threads: 0
I have two file one called show.php and one is show.tpl.
On show.php it has this code
On show.tpl it has this code
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
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();
•
•
•
•
<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
Hi Welbzobeng,
have a look at the query. After SELECT and before FROM it lists what attributes it will fetch for you.
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:
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
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.
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)
<td><a href="{$siteurl}/admin.php?view=admin_media&sort=artist"><b>Artist</b></a></td>
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.
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.
![]() |
Similar Threads
- Login Security ! (PHP)
- Look At My Log, Please (Viruses, Spyware and other Nasties)
- Creating an event or an action to a button. (PHP)
- Short guide to include RSS on your website (PHP)
- Browser Redirect/System Restore Problems/etc.... (Viruses, Spyware and other Nasties)
- replace address - how to? (PHP)
- command service help with a hijack log (Viruses, Spyware and other Nasties)
- random pages cannot be displayed IE prob (Viruses, Spyware and other Nasties)
- PC Cleaning Procedures & Detection Tools (Viruses, Spyware and other Nasties)
Other Threads in the PHP Forum
- Previous Thread: PHP: reporting upload progress
- Next Thread: how to update database on the basis of real tme entry
| Thread Tools | Search this Thread |
.htaccess ajax alexa apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email encode error fairness file files folder form forms function functions google href htaccess html image include indentedsubcategory insert integration ip java javascript joomla limit link login loop mail mail() menu mlm mod_rewrite multiple multipletables mysql newsletters oop paypal pdf php problem provider query radio random recursion regex remote script search server sessions simple sms soap source space sql structure syntax system table tutorial update upload url user validation validator variable variables video voteup web xml youtube





