Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 06-05-2003, 11:26 PM
gengar003's Avatar
gengar003 gengar003 is offline
 
Join Date: Apr 2002
Location: .::|The Matrix|::.
Posts: 181
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Querying and such.

I know there's a way to do this, but I'm not sure what....

I want to select information from a table in mySQL, only 2 fields in the table, `name`, and `data`, and I want it to repeat a piece of code until there's none left.... Hard to express my idea...

[poorexamplephp]
global $count
(Insert code looping until it's read all of table `query`)
$name = (insert way to call the current row's `name`field)
$dat = insert way to call the current row's `data`field)

echo $name;
echo "=";
echo $dat;
$count ++

(insert end of loop stuff)
[/poorexamplephp]

A
||
||

That... What should be `insert` 'ed?

Also, how would I query 2 out of 3 fields, or only 1?
Reply With Quote
  #2  
Old 06-06-2003, 10:13 AM
Dean C's Avatar
Dean C Dean C is offline
 
Join Date: Jan 2002
Location: England
Posts: 9,071
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
<?php
<table cellpadding=\"0\" cellspacing=\"0\" border=\"1\">
$getstuff = $DB_site->query("SELECT item1,item2 FROM table ORDER BY item1");
while(
$lala = $DB_site->fetch_array($getbattles))
{
<tr>
<td>
$lala[item1]</td>
<td>
$lala[item2]</td>
</tr>
}
</table>
?>
That will do it

- miSt
Reply With Quote
  #3  
Old 06-09-2003, 12:02 PM
gengar003's Avatar
gengar003 gengar003 is offline
 
Join Date: Apr 2002
Location: .::|The Matrix|::.
Posts: 181
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just one question.... where on earth did $getbattles come from? .... ? :confused"
Reply With Quote
  #4  
Old 06-09-2003, 12:10 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$getbattles should actually be $getstuff
Reply With Quote
  #5  
Old 06-09-2003, 12:41 PM
Chris M's Avatar
Chris M Chris M is offline
 
Join Date: Dec 2001
Location: Northampton, England
Posts: 6,186
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It is probably something he was thinking about at the time

And yes - '$getbattles' = '$getstuff'

Satan
Reply With Quote
  #6  
Old 06-09-2003, 02:37 PM
gengar003's Avatar
gengar003 gengar003 is offline
 
Join Date: Apr 2002
Location: .::|The Matrix|::.
Posts: 181
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Okay, using that code, I've modified it to run through a table, called "tacemon" until there's nothing left, and each time, execute a bit of code:

PHP Code:
$mypkmndat "";
$tacemonqing $DB_site->query("SELECT name,catchname FROM tacemonquery ORDER BY name"); 
while(
$loopy $DB_site->fetch_array($tacemonqing)) 

$th_rite_name $loopy[name];
$th_rong_name $loopy[catchname];


if (
$bbuserinfo[$catchname]=="1") { 

$mypkmndat .= "<img src=\"http://pgsforum.com/vb/images/tac/tac/caught/";
$mypkmndat .= $th_rite_name;
$mypkmndat .= ".gif\">"
} else  { 
}

 


$bbuserinfo['tacemon'] = $mypkmndat

$DB_site->query("UPDATE user SET tacemon = '".$bbuserinfo[tacemon]."' WHERE userid='".$bbuserinfo['userid']."' LIMIT 1"); 
Anyway, When I hard-code the code in the while loop for each entry in the DB table, it works, but not when I use the loop. However, when I place an "echo $loopy[name];" in the loop, but not in the if statement, It prints the names on the page, so I know the loop works.


This probably has to do with global/local variables, but I tired declaring $mypkmndat as global (Which I assume is the problem, since it's the variable that I want to use outside of the loop) but that didn't help.

Anyway, anyone know what I've done wrong?

EDIT: *sigh* after all that typing describing my problem, I found the answer going over my post. $catchname should've been $th_rong_name. I changed it, an' it works.

:dead: :nervous: :cry:

Now the real test will be how it handles me adding a new row...
Reply With Quote
  #7  
Old 06-09-2003, 03:10 PM
gengar003's Avatar
gengar003 gengar003 is offline
 
Join Date: Apr 2002
Location: .::|The Matrix|::.
Posts: 181
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Anyway, another question. I get this error:

Warning: Cannot use a scalar value as an array in /home/pgsforum/public_html/catch.php on line 55

Warning: Cannot use a scalar value as an array in /home/pgsforum/public_html/catch.php on line 56

Warning: Cannot use a scalar value as an array in /home/pgsforum/public_html/catch.php on line 99

Warning: Cannot use a scalar value as an array in /home/pgsforum/public_html/catch.php on line 115

on every vbhome(lite) page.

What would I look for to fix it? Is it something like trying to do

$var ="0";
$arrary[$var] = $arryvar?

(Quoted variable value used as thingy in an array?)

Plz help.

Also, the # of new threads, posts, articles, and messages aren't showing up....
Reply With Quote
  #8  
Old 06-09-2003, 07:09 PM
Chris M's Avatar
Chris M Chris M is offline
 
Join Date: Dec 2001
Location: Northampton, England
Posts: 6,186
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It is possible you globalised a variable used by vBhome(lite)...

Satan
Reply With Quote
  #9  
Old 06-09-2003, 07:53 PM
gengar003's Avatar
gengar003 gengar003 is offline
 
Join Date: Apr 2002
Location: .::|The Matrix|::.
Posts: 181
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I didn't add any global thingies, though...
Reply With Quote
  #10  
Old 06-10-2003, 02:32 PM
Dean C's Avatar
Dean C Dean C is offline
 
Join Date: Jan 2002
Location: England
Posts: 9,071
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

gengar - oopsiee at the copy and paste job and edit job from my battle script hehe

That's basically the jist of it though

- mISt
Reply With Quote
Reply

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

Forum Jump


All times are GMT. The time now is 06:49 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.05167 seconds
  • Memory Usage 2,263KB
  • 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
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)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_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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete