Click to See Complete Forum and Search --> : Cant get table results to show?


Breana
08-20-2007, 11:36 AM
Ok, i have a table called users and inside it is a table called points.
I want to show the users current points after they login.
I use $uid, as a global val so if it aint there it will show the else var...

I cam up with this php but it wont pull the number out?
1-through-5000 so it'll look like this.

If logged in, You Have 0 Points!
Not logged in, Please login to view points!

Now it works in part, i logout it will say please login and if i login it switches back over all ok but it just wont show the actual number they have...

<?
if (logincheck($uid, $upwd)) {
$sql = "SELECT points FROM users WHERE userid = $uid";
$result = mysql_query($sql ,$db);
echo ("You Have $points Points");
} else {
echo ("Error");
}
?>

And in my Whos Online:
<?
$sql = "SELECT userid FROM users";
$result = mysql_query($sql ,$db);
echo ("Total Members $userid");
}
?>
<?
$sql = "SELECT status FROM users_online_table";
$result = mysql_query($sql ,$db);
echo ("Whos Online $userid");
}
?>

What did i do wrong?

Declan1991
08-20-2007, 01:27 PM
$sql = "SELECT points FROM users WHERE userid = '$uid'";

Breana
08-20-2007, 01:43 PM
Hi, thanx for the reply, i just changed it but it still wont show the number of points they have... :(

<?
if (logincheck($uid, $upwd)) {
$sql = "SELECT points FROM users WHERE userid = '$uid'";
$result = mysql_query($sql ,$db);
echo ("You Have $points Points");
} else {
echo ("Error");
}
?>
Is there anything else wrong with it?
Like do i need to ad print value or something...:confused:

MrCoder
08-20-2007, 02:27 PM
<?
if(logincheck($uid, $upwd))
{
$points_sql = " SELECT
`points`
FROM
`users`
WHERE
`userid` = '".(int)$uid."'";

$points_result = mysql_query($points_sql ,$db);
$points_data = mysql_fetch_assoc($points_result);

echo ("You Have ".$points_data["points"]." Points");
} else {
echo ("Error");
}
?>

Breana
08-20-2007, 02:55 PM
YOU ARE THE MAN!!!

Thanx soooo much i get it now, well i partly get it lol, it works great!
So i can use that to try and get the total users working, i see the errors i did.
:rolleyes:

MrCoder
08-20-2007, 03:52 PM
Glad I could help mate, further reading (http://uk3.php.net/mysql).

Breana
08-21-2007, 09:02 AM
Mate lol, im a gurl...
jk, hey i have been trying to learn this but i am stuck again suprize suprize...

I want to make a page so it updates the users points if they post content, well on the page after they added the code image.
I made a link called Collect my points, and made a php called recivepoints.php.

And inside i got this to update the points tabe by there user name by 5 points.

<?
if(logincheck($uid, $upwd))
{
$points_sql = " UPDATE
`points`
FROM
`users`
WHERE
`userid` = '".(int)$uid."'" VALUES ('5');

$points_result = mysql_query($points_sql ,$db);
$points_data = mysql_fetch_assoc($points_result);
echo ('Points Updated, Total Game Points,&nbsp;<b><font color=\"#FF0000\">".$points_data["points"]." Now!')'
refresh timer=3 ('index.php')
}
?>

But it dont work, the points dont change, i had 5 total and it should havewent to 10... and the page dont automatickly refresh to the home page?
Any thoughts on this.