View Full Version : Help displaying mysql data

09-23-2004, 12:32 AM
Okay, I am making a script that is going to show someone's personal info using some cookies that are set when you log on. Using SELECT and a variable that is assigned the username cookie, I need to display their points. I just can't get it right! Could some one help me out on this? I'm so clueless :confused:

09-23-2004, 01:16 AM
You'll probably get better help if you pose more punctual questions + show us the code you already have.

09-23-2004, 01:21 AM
Well, you can also do it using SESSIONS... they will cancel out when you exit the browser though... giving it some extra security... you can still use cookies.


$sql = mysql_query("SELECT * FROM _____1_____ WHERE ____2_____",$connection) or print mysql_error();
$login_check = mysql_num_rows($sql);
if($login_check > 0)
while($row = mysql_fetch_array($sql))
foreach( $row AS $key => $val )
$$key = stripslashes( $val );


<?php echo $row["points"]; ?>

<?php } } ?>

Now I'm going to explain.

1. This is the table in your MySQL Database that you're selecting the data from.

2. The row to select the info from... for example selecting user "dnirvine" points is
username='dnirvine' Usually this is a variable such as

$username=$_SESSION["username"]; This takes the info from the session "username" and puts it into a variable for easy use.

<?php echo $row["points"]; ?> This echos the row "points" from the database.

Hope this helps.

09-23-2004, 01:42 AM
Thanks! :thumbsup:

09-23-2004, 01:50 AM
After all the taking I was finally able to help someone! :cool: :thumbsup: