jonhmatthew Posted February 20, 2010 Share Posted February 20, 2010 hey guys, I have a quick question. I've done everything to setup users to login my website (MySQL id,username, password). Now all I want to know is how to display information only on the logged in user's row (not the entire table) on a webpage. This will help me out tremendously, thanx! Here's what I have so far <? session_start(); if(!session_is_registered(myusername)){ header("location:home.php"); } ?> <html> <body> Login Successful </body> </html> <br><a href="http://x2broadcasting.com/loginhome.php" target="_top">Proceed Here</a> <br> or <br> <a href="http://www.x2broadcasting.com/logout.php" target="_top">Log Out</a>! <html> <body> <?php $username="jonhmatthew"; $password="*********"; $database="x2_2434451"; $localhost="sql8.bravehost.com"; mysql_connect($localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM Users" ; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> <table border="0" cellspacing="2" cellpadding="2"><tr> <th><font face="Arial, Helvetica, sans-serif">Value1</font></th> <th><font face="Arial, Helvetica, sans-serif">Value2</font></th> <th><font face="Arial, Helvetica, sans-serif">Value3</font></th> <th><font face="Arial, Helvetica, sans-serif">Value4</font></th> <th><font face="Arial, Helvetica, sans-serif">Value5</font></th> </tr> <?php $i=0; while ($i < $num) { $f1=mysql_result($result,$i,"Production Appointments"); $f2=mysql_result($result,$i,"Available Commercials"); $f3=mysql_result($result,$i,"Now AIring"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f5; ?></font></td> </tr> <?php $i++; } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/192711-need-simple-help/ Share on other sites More sharing options...
aruns Posted February 20, 2010 Share Posted February 20, 2010 Save User id When user is logged in like this... $query = mysql_query("SELECT * FROM users WHERE username = '$username' and password = '$password'")or die("Error:" . mysql_error()); $rlt = mysql_fetch_array($query); $count = mysql_num_rows(); if($count == 1){ session_register("username"); $_SESSION['USERID'] = $rlt['id']; }else{ echo "Invalid USer....."; } $qry = mysql_query("SELECT * FROM users WHERE id = '".$_SESSION['USERID']."'")or die("ERROR:" . mysql_error()); $rst = mysql_fetch_array($qry); extract logged in user data through $rst Link to comment https://forums.phpfreaks.com/topic/192711-need-simple-help/#findComment-1015178 Share on other sites More sharing options...
jonhmatthew Posted February 21, 2010 Author Share Posted February 21, 2010 How do I "extract logged in user data through $rst" ? This is the message I get: Warning: Wrong parameter count for mysql_num_rows() in /misc/22/000/244/268/0/user/web/x2broadcasting.com/login_success.php on line 35 Invalid USer..... = ------------------my code------------------------ <? session_start(); if(!session_is_registered(myusername)){ header("location:home.php"); } ?> <html> <body> Login Successful </body> </html> <br><a href="http://x2broadcasting.com/loginhome.php" target="_top">Proceed Here</a> <br> or <br> <a href="http://www.x2broadcasting.com/logout.php" target="_top">Log Out</a>!<html> <body> <?php $username="jonhmatthew"; $password="******"; $database="x2_2434451"; $localhost="sql8.bravehost.com"; mysql_connect($localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $result=mysql_query($query); $query = mysql_query("SELECT * FROM Users WHERE username = '$username' and password = '$password'")or die("Error:" . mysql_error()); $rlt = mysql_fetch_array($query); $count = mysql_num_rows(); if($count == 1){ session_register("username"); $_SESSION['USERID'] = $rlt['id']; }else{ echo "Invalid USer....."; } $qry = mysql_query("SELECT * FROM Users WHERE id = '".$_SESSION['USERID']."'")or die("ERROR:" . mysql_error()); $rst = mysql_fetch_array($qry); mysql_close(); ?> <table border="0" cellspacing="2" cellpadding="2"><tr> <th><font face="Arial, Helvetica, sans-serif">Value1</font></th> <th><font face="Arial, Helvetica, sans-serif">Value2</font></th> <th><font face="Arial, Helvetica, sans-serif">Value3</font></th> <th><font face="Arial, Helvetica, sans-serif">Value4</font></th> <th><font face="Arial, Helvetica, sans-serif">Value5</font></th> </tr> <?php $i=0; while ($i < $num) { $f1=mysql_result($result,$i,"Production Appointments"); $f2=mysql_result($result,$i,"Available Commercials"); $f3=mysql_result($result,$i,"Now AIring"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f5; ?></font></td> </tr> <?php $i++; } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/192711-need-simple-help/#findComment-1015453 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.