Register Members List Search Today's Posts Mark Forums Read

Reply
 
Article Options
SELECT FROM database
flup
Join Date: Jan 2002
Posts: 872

Maastricht, NL
by flup flup is offline 02 May 2003

Ok, next step is to get information FROM a database, and let it display on your webpage.
__________________________________________________

We are still using the same table as in the previous artikel (tabel)
I will give you the code, and then explain it all to you.

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

In this part we have called ALL (*) information from table tabel, in this script it won't display anything.

The part above, the connection to the database, has been explained in the previous aricle

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Select all (*) from the database, or give me the mysql error.
Very easy IMO

Now let's go to the next step!! Show the results on a webpage.

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Ok, now we've displayed all information of table tabel, on a page.
I assume you don't really know what is going on, so i'll explain the part to you

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

The echo code you will know i guess, this is just a simple code to write something on a webpage, everything you want to echo, has to be in the double quote ("). Things here displayed are:
naam, email, titel, info

And like you see, it will display all info, the layout of this is quite simple, but you can edit it all the way you want (per example add it into a table)
When you've openen an echo code, don't use double quote in the double quotes, but use singel quotes instead.



To go one more step deeper into mySQL i want to explain the WHERE function in a mySQL query:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Like you see i've only edited a little part of the query, and that is:
WHERE naam='flup'

Or: Selected everything in the table 'table' where 'naam' is equal to flup

You also could replace: naam='flup' to email='[email protected]' or titel='administrator'

Good luck!!

Last edited by flup; 02 May 2003 at 11:03..
Views: 3749
Reply With Quote
Comments
  #2  
Old 02 May 2003, 11:01
flup's Avatar
flup flup is offline
 
Join Date: Jan 2002
Real name: Joshua
Click here for the tutorial: Instert into database
Reply With Quote
  #3  
Old 02 May 2003, 19:51
Dean C's Avatar
Dean C Dean C is offline
 
Join Date: Jan 2002
Real name: Dean Clatworthy
Wow you use fetch_object - i never use classes,methods or objects apart from the built in $db_site object in vbulletin

- miSt
__________________
Dean Clatworthy - Web Developer/Designer
Reply With Quote
  #4  
Old 02 May 2003, 20:46
flup's Avatar
flup flup is offline
 
Join Date: Jan 2002
Real name: Joshua
Hmmmz, getch_object works good very good IMO.
But this tutorials is more for the noobs wich are going to test this outside vB
Reply With Quote
  #5  
Old 04 Jun 2006, 00:23
jim6763nva's Avatar
jim6763nva jim6763nva is offline
 
Join Date: Oct 2005
Real name: Jim
It would be nice to see a tutorial on how to do SELECTS, INSERTS, UPDATES, and DELETES using the native vbulletin $db_site methods and functions. I'd like to write a custom module for vba CMPS too but I'm not sure where to start or how to go about it.

Thanks,
Jim
Reply With Quote
  #6  
Old 04 Jun 2006, 02:28
Kirk Y's Avatar
Kirk Y Kirk Y is offline
 
Join Date: Apr 2005
Basically just use:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

That's pretty much it. Use query_first to generate arrays.
__________________
Former vBulletin.org Staff Member

Please feel free to re-use any of the code in any of my projects submitted to vB.org, so long as original attribution is retained.
Reply With Quote
  #7  
Old 04 Jun 2006, 02:36
noppid noppid is offline
 
Join Date: Mar 2003
Originally Posted by flup
Ok, next step is to get information FROM a database, and let it display on your webpage.
__________________________________________________

We are still using the same table as in the previous artikel (tabel)
I will give you the code, and then explain it all to you.

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

In this part we have called ALL (*) information from table tabel, in this script it won't display anything.

The part above, the connection to the database, has been explained in the previous aricle

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Select all (*) from the database, or give me the mysql error.
Very easy IMO

Now let's go to the next step!! Show the results on a webpage.

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Ok, now we've displayed all information of table tabel, on a page.
I assume you don't really know what is going on, so i'll explain the part to you

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

The echo code you will know i guess, this is just a simple code to write something on a webpage, everything you want to echo, has to be in the double quote ("). Things here displayed are:
naam, email, titel, info

And like you see, it will display all info, the layout of this is quite simple, but you can edit it all the way you want (per example add it into a table)
When you've openen an echo code, don't use double quote in the double quotes, but use singel quotes instead.



To go one more step deeper into mySQL i want to explain the WHERE function in a mySQL query:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Like you see i've only edited a little part of the query, and that is:
WHERE naam='flup'

Or: Selected everything in the table 'table' where 'naam' is equal to flup

You also could replace: naam='flup' to email='[email protected]' or titel='administrator'

Good luck!!

Did you really call your table "tabel"?
__________________
Add a photo gallery garage to your auto forum and get noticed by your members. Find out how at the vBulletin Computer Help Forum.
An informed rider makes their first destination the motorcycle forum at rider info.
Reply With Quote
  #8  
Old 04 Jun 2006, 16:46
rogersnm's Avatar
rogersnm rogersnm is offline
 
Join Date: Apr 2006
Location: Cyberspace, UK
Real name: Nick Rogers
lol,

did you really need to quote everything to say that?
Reply With Quote
  #9  
Old 04 Jun 2006, 16:54
jim6763nva's Avatar
jim6763nva jim6763nva is offline
 
Join Date: Oct 2005
Real name: Jim
Originally Posted by acidburn0520
Basically just use:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

That's pretty much it. Use query_first to generate arrays.
Thanks! I've played around with this a little.. but now I can't seem to display the results. I'm trying to use some custom templates. Are there examples on how to do this? It would be nice if there was a way to debug variables or to see what variables were currently loaded by the system too. I've tried to study code from other mods and they use system arrays and variables that I don't have a clue what they are for or if I should be using them in my code.

Any and all help on this will be deeply appreciated, :banana:
Thanks again!

Jim
Reply With Quote
  #10  
Old 04 Jun 2006, 16:56
rogersnm's Avatar
rogersnm rogersnm is offline
 
Join Date: Apr 2006
Location: Cyberspace, UK
Real name: Nick Rogers
just been messing around to...

where is the forum info stored in the db and what external code would i have to use to get them?
ie.
$forum['threadcount']
$forum['replycount']
$vbulletin->userstats['numbermembers']

Regards,
Nick.
Reply With Quote
  #11  
Old 12 Jun 2006, 01:09
Kirk Y's Avatar
Kirk Y Kirk Y is offline
 
Join Date: Apr 2005
Say we use this query for an example:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

If the DB column you wanted to get data from was called "example", you'd use this to call the data:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

The outputted data is whatever was stored in the column you called.
__________________
Former vBulletin.org Staff Member

Please feel free to re-use any of the code in any of my projects submitted to vB.org, so long as original attribution is retained.
Reply With Quote
  #12  
Old 18 Sep 2006, 19:07
vietkieu_cz vietkieu_cz is offline
 
Join Date: Dec 2005
Originally Posted by acidburn0520
Basically just use:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

That's pretty much it. Use query_first to generate arrays.
And how do I show the queries on forum (thread)???
I do not know how to use it, please help me. Thank you very much

(Normal PHP is: ex:

$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo {$row['threadid']}".
"{$row['title']}".
"<br/>";
}
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Article Options

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


New To Site? Need Help?

All times are GMT. The time now is 09:20.

Layout Options | Width: Wide Color: