Jump to content

Recommended Posts

I'm trying to load up data where by the session is carrying the user ID.. and i need the session to call up the user table which is working fine. But i also need to call up info about gangs that the user is in. Now it gets complicated cos the user could be 1 of 30 members (30 being the max a gang gang can have).

 

But how is this done? This is what i got at the moment. But this is only calling up the one table. I need this now to also check if the user ID is in another table which could be in a possible 30 fields.

 

$GetUserID = mysql_query("SELECT * FROM userregistration
				WHERE UserID='{$_SESSION['Current_User']}'");

// Fetch the row from the database
if (!($row = mysql_fetch_assoc($GetUserID))) {
echo "User not found!";
exit;
}

// Display user's info
$UserId = $row["UserID"];
$HandMoney = $row["MoneyInHand"];

 

In the "gangs" table there is this:

 

Member1

Member2

 

And so on right up to Member30. The user could be in any of these 30 fields.. once it finds that it needs to be able to then fetch it and then be able to display it like shown in the above code. There is no echo how ever but thats cos this is an "include". The echo's are on the html files which is separate.

Link to comment
https://forums.phpfreaks.com/topic/64871-session-to-query-multiple-tables-fields/
Share on other sites

May I suggest you look into some database normalization tutorials, having the fields Member1, member2 etc etc is a pretty poor design which will make you queries much more difficult and less efficient.

 

While your at it, find some tutorials on joins in mysql, this will help you format your queries.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.