Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-28-2002, 08:23 PM
Matt's Avatar
Matt Matt is offline
 
Join Date: Oct 2001
Location: UK
Posts: 157
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Stuck....

aranoid: Me thick....

Me need help........



Whats wrong with this please? I am so confused with what this even does lol so if someone could exlplain that would be great

Code:
$query = "SELECT fanfic_authors.name, fanfic_authors.email, fanfic_contents.author, fanfic_contents.title, fanfic_contents.rating FROM fanfic_authors, fanfic_contents WHERE fanfic_authors.id = fanfic_contents.author GROUP BY fanfic_contents.author, fanfic_contents.title ORDER BY " . $sort . ",title LIMIT " . $start . ", 50";
$result = mysql_query($query);

while($row = mysql_fetch_array($result)){
print($row[title] . "<br>");
}
Reply With Quote
  #2  
Old 05-28-2002, 09:51 PM
Dark_Wizard Dark_Wizard is offline
 
Join Date: Nov 2001
Location: North Carolina
Posts: 1,251
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Whoa! Can you post the db schema? Both tables that is...then we can go from there...
Reply With Quote
  #3  
Old 05-29-2002, 12:02 AM
Matt's Avatar
Matt Matt is offline
 
Join Date: Oct 2001
Location: UK
Posts: 157
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks!

fanfic_authors
id int(11) NOT NULL auto_increment,
name varchar(100) NOT NULL default '',
email varchar(100) NOT NULL default '',
PRIMARY KEY (id)
TYPE=MyISAM;

fanfic_contents
id int(11) NOT NULL auto_increment,
title varchar(255) NOT NULL default '',
disclaimer text NOT NULL,
summary text NOT NULL,
spoilers text NOT NULL,
season int(11) NOT NULL default '0',
author int(11) NOT NULL default '0',
rating int(11) NOT NULL default '0',
content text NOT NULL,
notes text NOT NULL,
PRIMARY KEY (id)
TYPE=MyISAM;
Reply With Quote
  #4  
Old 05-29-2002, 12:08 AM
Matt's Avatar
Matt Matt is offline
 
Join Date: Oct 2001
Location: UK
Posts: 157
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just so you know what its for I am trying to do a fan fiction archive for my site and looked at someone elses code which was set out similar to this. Before that I had :

SELECT * FROM fanfic_contents ORDER BY..........

I just wanted somehow to make it a bit easier and to involve less queries. The problem being that the author info and the actual fan fiction are stored in different tables.

So I basically have this code and have a vague idea of what its doing but no real understanding of it :S
Reply With Quote
  #5  
Old 05-29-2002, 08:56 AM
Logician's Avatar
Logician Logician is offline
 
Join Date: Nov 2001
Location: inside vb code
Posts: 4,449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You didnt write what kind of result you want your query to return but at the first glance it seems that GROUP BY is redundant in this query..

If what you want to return is ALL results in fanfic_authors table (combined with relevant results from the contents table), this should work fine:

$query = "SELECT * FROM fanfic_authors a, fanfic_contents c WHERE a.id = c.author";
Reply With Quote
  #6  
Old 05-29-2002, 11:26 AM
Matt's Avatar
Matt Matt is offline
 
Join Date: Oct 2001
Location: UK
Posts: 157
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Basically I am trying to code the page where it lists the authors/titles/ratings etc 50 to a page. With a next link at the bottom if there are more than 50 results stored in that category.

I just thought that there would be an easier way to me doing like 10 queries. One to get the authors name and email, one to get the rating, one to get the title etc....

So I really want :

AUTHOR TITLE RATING CHAPTERS
Matt Title Here G [1] [2]

Something like that basically. Then when you click on the header of each column it will sort the results by that.
Reply With Quote
  #7  
Old 05-29-2002, 12:05 PM
Logician's Avatar
Logician Logician is offline
 
Join Date: Nov 2001
Location: inside vb code
Posts: 4,449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, modifying my code with LIMIT and SORT should do the trick, like:

$query = "SELECT * FROM fanfic_authors a, fanfic_contents c WHERE a.id = c.author AND a.id>$var ORDER BY ".$sort." LIMIT 50 ";

Now you have to pass your script the last pulled author id as $var, like:

while($row = mysql_fetch_array($result))
{
print($row[title] . "<br>");
$var=(int)$row[author];
}

If there are more than 50 records call your script like:
'<a href="yourscript.php?var='.$var.'>click here to get more</a>'

Needless to say in the first run, $var=0
Reply With Quote
  #8  
Old 05-29-2002, 09:11 PM
Matt's Avatar
Matt Matt is offline
 
Join Date: Oct 2001
Location: UK
Posts: 157
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Anywhere you would suggest that I would find a good tutorial for all this as I still don't totally get it and I will need to adapt it to other areas as well.

Thanks for your help so far
Reply With Quote
  #9  
Old 05-30-2002, 05:47 AM
Logician's Avatar
Logician Logician is offline
 
Join Date: Nov 2001
Location: inside vb code
Posts: 4,449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

sorry I dont know a basic tutorial for this feature on the net, but if you can find it somewhere and study it for a while then you can check "forumdisplay.php" and "showthread.php" of vb to get an advanced lesson. They use the same method. But their structure is way to complex for a newbie
Reply With Quote
Reply


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

Forum Jump


All times are GMT. The time now is 08:08 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.13089 seconds
  • Memory Usage 2,243KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete