Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-29-2004, 05:57 PM
ATLien's Avatar
Contributing Member
 
Join Date: 10-13-03
Location: Atlanta, GA
Posts: 1,135
iTrader: 0 / 0%
ATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really nice
Send a message via AIM to ATLien Send a message via Skype™ to ATLien
Top 10 script problems.

Hey everyone, i am trying to create a Top 10 script, and I am having problems. The way my tables are setup, is their is a table called ratings, that logs every rating of everything ont he site, then their is a feild that is item_id this relates to another table that has the item info in it. I am trying to take the average of ratings, find the top to for each item and match the item_id with the id int eh tutorials table, then out put the top 10. Here is what I have now:

[code:1:84317cc003] <?PHP
$querytut = "SELECT a.tutorial_id, a.tutorial_title, b.item_id, AVG(b.rating) as average FROM tutorials as a, ratings as b";
$querytut .= " WHERE a.tutorial_id='b.item_id' AND b.item_type='tutorial' GROUP BY a.tutorial_id ORDER BY average desc LIMIT 10";
$tutinfo = mysql_query($querytut) or die(mysql_error());
while($data=mysql_fetch_assoc($tutinfo)) {
$id = $data['tutorial_id'];
$rate = round($data['average'],2);
var_dump($data);
?>
<tr>
<td><a href="http://www.Graphics-Central.com/tutorials/index.php?id=<?PHP echo $data['tutorial_id']; ?>"><?PHP echo $data['tutorial_title']; ?></a> <?PHP echo $rate; ?></td>
</tr>
<?PHP
}
?>[/code:1:84317cc003]

I am not getting any errors, or results.
Digg this Post!Add Post to del.icio.us
Reply With Quote
  #2 (permalink)  
Old 05-29-2004, 06:03 PM
kwvarga's Avatar
Possible Terrorist
 
Join Date: 10-13-03
Location: Tuscaloosa, AL or Atlanta
Posts: 2,504
iTrader: 0 / 0%
kwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web pro
Send a message via AIM to kwvarga
ahhh.. try taking the ' ' off of b.item_id in the first where clause
__________________
http://www.kylevarga.com - My blog.
Digg this Post!Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Comment Script problems E_Igho Coding Forum 10 12-02-2006 01:46 AM
database problems or script problem? Julie Coding Forum 2 12-07-2005 07:57 AM
Problems with Login Script Izzmo Coding Forum 15 02-10-2004 03:57 PM


Sponsor Links
Get exposure! Contextual Links V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 07:55 AM.
© Copyright 2008 V7 Inc
Powered by vBulletin
Copyright © 2000-2009 Jelsoft Enterprises Limited.


Search Engine Optimization by vBSEO 3.3.0 ©2009, Crawlability, Inc.