| |
|
|
| |
|
|
| |
|
Need Some PHP Help
06.22.02, 17:52:45
|
|
|
|
Post #1 (permalink) |
|
|
| |
|
|
On any php files for vB, you have to use:
require('./global.php');
So you can query the database using $DB_site->query
If I was going to make a php file that's NOT in my root directory, how would I make it still be able to query the database like that? |
|
|
|
|
|
|
| maybe try require('http://www.punkmusicrocks.com/global.php'); |
|
|
|
|
|
|
That's not the exact url, but I'll give it a try and see if it works.
EDIT: That didn't work. That's good, otherwise you could point that to anyone's global.php and start messing with their database. |
Last edited by AnkisethGallant : 06.22.02 at 19:11:53.
|
|
|
|
|
|
well....
chdir("community");
require("./global.php");
chdir("../");
that's the way i have it for files in the root. and community is the forums dir. |
______________________________________

|
|
|
|
|
|
Thanks rake.
Also, if I have info in a table for every user, say for example Level like FFR would, how do I pull out all the values and find the highest? |
|
|
|
|
|
|
| $DB_site->query_first("SELECT * FROM user ORDER BY level DESC LIMIT 1"); |
|
|
|
|
|
|
| Ah thanx rake I was just wondering how to do that myself and if I wanted posts or RP I would just change the level to post or points right? |
______________________________________
Arielle
Aerith_Freak | aerithfreak | Ethereal
Former Site Manager and Forum Administrator of Final Fantasy Republic 2002-2005
|
|
|
|
|
|
Yes Aerith.
When you do that query Mewtwo, will you have to store it as an array ($level = $DB_site...)?
Also, if I want the person with the second highest level, do I change the DESC LIMIT to 2? |
|
|
|
|
|
|
*does happy dance*
Ok I think I got it,
*runs off to add latest addition to Shop directory* |
|
|
|
|
|
|
Quote:
Originally posted by AnkisethGallant
Yes Aerith.
When you do that query Mewtwo, will you have to store it as an array ($level = $DB_site...)?
Also, if I want the person with the second highest level, do I change the DESC LIMIT to 2?
|
yes, you'll have to store it in a variable.
$topuser = $DB_site->query_first("SELECT * FROM user ORDER BY level DESC LIMIT 1");
then you can use the topuser variable for the user info: $topuser[username], $topuser[userid], $topuser[level] etc.
if you want to get more results you can modify limit and use the fetch_arrray, like this:
$topusers = $DB_site->query("SELECT * FROM user ORDER BY level DESC LIMIT 3");
while($topuser = $DB_site->fetch_array($topusers)) {
here you can use the $topuser variable.
}
but if you want to get only the second row, then use this:
$topuser = $DB_site->query_first("SELECT * FROM user ORDER BY level DESC LIMIT 1,2");
not sure, haven't tried it, but it should return only the second row. |
|
|
|
|
| |