vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Repeating the same query (https://vborg.vbsupport.ru/showthread.php?t=93056)

Andreas 07-28-2005 08:25 AM

Quote:

Originally Posted by Boofo
schema=scheme?

Whoops! Schema is german, sorry for that ;)

Lionel 07-28-2005 08:34 AM

1 Attachment(s)
ok thanks. I am putting only a few, because I have hundreds of data

PHP Code:

CREATE TABLE `soundtracks` (
`
songidsmallint(5unsigned NOT NULL auto_increment,
`
titlevarchar(100NOT NULL default '',
`
urlvarchar(100NOT NULL default '',
`
playssmallint(5) default '0',
`
activeint(2NOT NULL default '0',
`
useridint(11NOT NULL default '0',
`
usernamevarchar(225NOT NULL default '',
`
rated_qtyint(5NOT NULL default '0',
`
ratingint(5NOT NULL default '0',
`
announceint(2NOT NULL default '0',
`
genrevarchar(50NOT NULL default '',
PRIMARY KEY (`songid`)
TYPE=MyISAM AUTO_INCREMENT=68 ;
-- 
-- 
Dumping data for table `soundtracks`
-- 
INSERT INTO `soundtracksVALUES (3'Chov''Chov.mp3'2214'haitiwebs'151'Carimi');
INSERT INTO `soundtracksVALUES (2'Solda Jah''09 - Solda Jah.mp3'3614'haitiwebs'3150'Jah Nesta');
INSERT INTO `soundtracksVALUES (4'Kidnapping''Kidnapping.mp3'1714'haitiwebs'151'Carimi');
INSERT INTO `soundtracksVALUES (5'Mwen sou''Mwen sou.mp3'1414'haitiwebs'000'Carimi');
INSERT INTO `soundtracksVALUES (6'Pitit sa''Pitit sa.mp3'2314'haitiwebs'130'Carimi');
INSERT INTO `soundtracksVALUES (7'Por favor''CARIMI -por favor.mp3'4214'haitiwebs'150'Carimi');
INSERT INTO `soundtracksVALUES (8'Two ta''Two ta - 06.mp3'814'haitiwebs'000'Jah Nesta');
INSERT INTO `soundtracksVALUES (9'Chasse ? l''enfant''Chasseenfant- 03.mp3'1514'haitiwebs'000'Jah Nesta'); 

And the crazy thing I am doing:

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=" &middot; <a href=\"showproduct.php?product=$product&do=main&mysong=$clip2id\">$clip2</a>"
        } 
 
$extra3songsquery $DB_site->query("SELECT songid, title, url FROM soundtracks WHERE title='$extra3' AND active=1");
 while(
$extra3songrow $DB_site->fetch_array($extra3songsquery)) 
        {    
           
$clip3=$extra3songrow['title'];
    
$clip3id=$extra3songrow['songid'];
    
$clip3url=$extra3songrow['url'];
    
$extra3=" &middot; <a href=\"showproduct.php?product=$product&do=main&mysong=$clip3id\">$clip3</a>"
        } 
 
$extra4songsquery $DB_site->query("SELECT songid, title, url FROM soundtracks WHERE title='$extra4' AND active=1");
 while(
$extra4songrow $DB_site->fetch_array($extra4songsquery)) 
        {    
           
$clip4=$extra4songrow['title'];
    
$clip4id=$extra4songrow['songid'];
    
$clip4url=$extra4songrow['url'];
    
$extra4=" &middot; <a href=\"showproduct.php?product=$product&do=main&mysong=$clip4id\">$clip4</a>"
        } 
 
$extra5songsquery $DB_site->query("SELECT songid, title, url FROM soundtracks WHERE title='$extra5' AND active=1");
 while(
$extra5songrow $DB_site->fetch_array($extra5songsquery)) 
        {    
           
$clip5=$extra5songrow['title'];
    
$clip5id=$extra5songrow['songid'];
    
$clip5url=$extra5songrow['url'];
    
$extra5=" &middot; <a href=\"showproduct.php?product=$product&do=main&mysong=$clip5id\">$clip5</a>"
        } 
 
$extra6songsquery $DB_site->query("SELECT songid, title, url FROM soundtracks WHERE title='$extra6' AND active=1");
 while(
$extra6songrow $DB_site->fetch_array($extra6songsquery)) 
        {    
           
$clip6=$extra6songrow['title'];
    
$clip6id=$extra6songrow['songid'];
    
$clip6url=$extra6songrow['url'];
    
$extra6=" &middot; <a href=\"showproduct.php?product=$product&do=main&mysong=$clip6id\">$clip6</a>"
        } 


how I am displaying it now:

Quote:

<span class="smallfont">$extra1$extra2$extra3$extra4$ext ra5$extra6</span>
and the result attached (I have 2 now, still testing)

Thanks.

Andreas 07-28-2005 08:41 AM

OK. Now if you could also post example Values for extra1, etc. and what should be the output then, I might be able to help you ;)

Lionel 07-28-2005 08:45 AM

Values for extras are exactly the same as in title.
we put in a different song title in each one of the 6 extras textboxes. Then we query db. If title matches any extra, then we grab the info for that title.

Marco van Herwaarden 07-28-2005 08:47 AM

Please read post #5 again (mind that '=' is changed to '.='), i think that is your solution.

Lionel 07-28-2005 08:58 AM

Quote:

Originally Posted by MarcoH64
Please read post #5 again (mind that '=' is changed to '.='), i think that is your solution.

Phew! Thanks Marco. I would have never figured out that one. As a rule, when do we put a dot? LOL, looks like I will have to go back to some other scripts I made and start putting dots all over.

Andreas 07-28-2005 09:01 AM

= is an assignment, .= is a concatenation
$foo = 'bar';
$foo = 'bar';
results is $foo being 'bar';

$foo = 'bar'
$foo .= 'bar'
results in $foo being 'barbar'

Lionel 07-28-2005 09:03 AM

Got it. Thanks. Not bad after 6 hours for just one dot :-)

Andreas 07-28-2005 09:04 AM

Hmm ... lol.
SCNR ;)

Marco van Herwaarden 07-28-2005 09:06 AM

Examples:
PHP Code:

$line '';
foreach (array(
'line1\n''line2\n') AS $text)
{
 
$line $text;


$line will now contain
Code:

line2
, since that was the last assignment.

2nd example:
PHP Code:

$line '';
foreach (array(
'line1\n''line2\n') AS $text)
{
 
$line .= $text;


$line will now contain:
Code:

line1
line2



All times are GMT. The time now is 10:43 PM.

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.01158 seconds
  • Memory Usage 1,802KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (4)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete