I need some mySQL help, any guru's in here?

777php

Diamond Member
Jul 17, 2001
3,498
0
0
I am relatively inexperienced when it comes to mySQL or SQL as a language. I am just now beginning to learn it. I have a little problem with a site that I am working on, I've been getting help at the sofware forum but I would like a little more input from others. (No offense joinT, you've helped me out a bit)

Basically I am trying to have mysql pass the user variable $PHP_AUTH_USER which is created by an .htaccess prompt. Then I need the $PHP_AUTH_USER or user id to be crossrefenced in the mySQL database with an $access_id entry. If the user has the proper $access_id, I need for PHP to then redirect them to the proper page, and if not I will kick them to another page. I can handle the PHP portion of the code but I just need the sql help.

You can read more in my original thread. Thanks guys!

thread here
 

docmanhattan

Golden Member
Jul 31, 2001
1,332
0
0
i posted this in the other thread you started as well.

I'm assuming that $access_id is in the same table, but if not you could link them with a foriegn key probably. But anyways:

$sql = "SELECT access_id from your_table where user_id = '$PHP_AUTH_USER'";

//db connection stuff here
//run query

while($row=mysql_fetch_array($query_result)) {
$access_id = $row['access_id'];

switch($access_id) {
case 1:
//some code
break;
case 2:
//some code
break;
case 3:
//some code
break;
deafault:
//some code
}
}

i hope this helps some.

:D

edit: of course, looking at what i wrote, I'm not checking for the possibility of an empty result.