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 07-28-2005, 07:40 AM
Lionel Lionel is offline
 
Join Date: Dec 2001
Location: Delray Beach, Florida
Posts: 3,277
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Repeating the same query

I am doing a query where the choices are title=$extra1 or title=$extra2 or title=$extra3 (up to 6 extras)

I am getting the same result for all, and I ended up doing the below 6 times.

Surely there must be another way to do this to avoid the 6 queries?

PHP Code:
 $extra1songsquery $DB_site->query("SELECT songid, title, url FROM soundtracks WHERE title='$extra1' AND 
active=1"
);
while(
$extra1songrow $DB_site->fetch_array($extra1songsquery)) 
        {    
         
$clip1=$extra1songrow['title'];
    
$clip1id=$extra1songrow['songid'];
    
$clip1url=$extra1songrow['url'];
    
$extra1="<a href=\"showproduct.php?product=$product&do=main&mysong=$clip1id\">$clip1</a>"
        } 
 
$extra2songsquery $DB_site->query("SELECT songid, title, url FROM soundtracks WHERE title='$extra2' AND 
active=1"
);
while(
$extra2songrow $DB_site->fetch_array($extra2songsquery)) 
        {    
         
$clip2=$extra2songrow['title'];
    
$clip2id=$extra2songrow['songid'];
    
$clip2url=$extra2songrow['url'];
    
$extra2="<a href=\"showproduct.php?product=$product&do=main&mysong=$clip2id\">$clip2</a>"
        } 
Reply With Quote
  #2  
Old 07-28-2005, 07:47 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
$DB_site->query("SELECT songid, title, url FROM soundtracks WHERE title IN ('$extra1', '$extra2', '$extra3') AND active=1"); 
?
Reply With Quote
  #3  
Old 07-28-2005, 07:48 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can't you do a:

Quote:
SELECT * FROM
Reply With Quote
  #4  
Old 07-28-2005, 07:58 AM
Lionel Lionel is offline
 
Join Date: Dec 2001
Location: Delray Beach, Florida
Posts: 3,277
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by KirbyDE
PHP Code:
$DB_site->query("SELECT songid, title, url FROM soundtracks WHERE title IN ('$extra1', '$extra2', '$extra3') AND active=1"); 
?
That does not return the other items (url and songid).
This is a non Vb script where I cannot do a normal eval for a templatebit.
when I do:

PHP Code:
 $extra1songsquery $DB_site->query("SELECT songid, title, url FROM soundtracks WHERE WHERE title IN ('$extra1', '$extra2', '$extra3') AND active=1");
 
while(
$extra1songrow $DB_site->fetch_array($extra1songsquery)) 
        {    
         
$clip1=$extra1songrow['title'];
    
$clip1id=$extra1songrow['songid'];
    
$clip1url=$extra1songrow['url'];
    
$extra1="<a href=\"showproduct.php?product=$product&do=main&mysong=$clip1id\">$clip1</a>"
        } 
and put in template:

$extra1

only the first one is returned. The others have no results.

Quote:
Originally Posted by Boofo
Can't you do a:
can't do that. It's the WHERE clause that is giving me a hard time. Too many WHERE
Reply With Quote
  #5  
Old 07-28-2005, 08:02 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I dont seem to understand your problem

Please post a scheme of your Table with example Data, the values for extra1, extra2, etc. and what you would like to have returned.

But I think your problem does have nothing to do with the query:

PHP Code:
$extra1.="<a href=\"showproduct.php?product=$product&do=main&mysong=$clip1id\">$clip1</a>"
Reply With Quote
  #6  
Old 07-28-2005, 08:11 AM
Lionel Lionel is offline
 
Join Date: Dec 2001
Location: Delray Beach, Florida
Posts: 3,277
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, here is what I am doing:

When I input the data in that page

I have $desc which I am using to parse Geek autolink to lyrics.
I have 6 extra fields that I could use. I am using them to query a database of MP3s. I put the exact title in the various extra fields. Then I do a query in the php. If the soundtracks title matches one of the extras, then I need to get the info for each one of the extras (I have embeded a player in the page and when you click on the link at the bottom of the page, it plays the selected clip). My method works, but I have to do the same query six times.
Reply With Quote
  #7  
Old 07-28-2005, 08:14 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The linked page is in french and I understand nothing

Please, just post your table scheme, example data, the extraX values and which rows you want to have selected for those.
Reply With Quote
  #8  
Old 07-28-2005, 08:19 AM
Lionel Lionel is offline
 
Join Date: Dec 2001
Location: Delray Beach, Florida
Posts: 3,277
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh well, sorry for the French.

I am no guru. What you saw is from painfully put together hours of trial and error spaghetti codes. I don't even know what you mean by schema.
Reply With Quote
  #9  
Old 07-28-2005, 08:23 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lionel
Oh well, sorry for the French.

I am no guru. What you saw is from painfully put together hours of trial and error spaghetti codes. I don't even know what you mean by schema.
schema=scheme?
Reply With Quote
  #10  
Old 07-28-2005, 08:23 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is the scheme of Table datastore:

Code:
CREATE TABLE `datastore` (
  `title` varchar(15) NOT NULL default '',
  `data` mediumtext  NOT NULL,
  PRIMARY KEY  (`title`)
);
And this is example Data for this Table:
Code:
INSERT INTO `datastore` VALUES ('cron', '1122540900');
INSERT INTO `datastore` VALUES ('banemail', '');
Or in other words: A (part) dump of the Table.
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 11:37 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06844 seconds
  • Memory Usage 2,289KB
  • Queries Executed 14 (?)
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
  • (2)bbcode_code
  • (5)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete