chanfuterboy Posted August 10, 2009 Share Posted August 10, 2009 hi, I try but I am doing something wrong. I want the user ' lady1 ' in table of username, be able to see a link that i called crew2.php. the rest users will not see the link, help me figur out it, in my code below if(mysql_num_rows($sql) > 0){ // Loop through the results while($row = mysql_fetch_array($sql)){ $username = $row['username']; $password = $row['password']; $email = $row['email']; if ($username == lady1) { print "click, click > <a href='crew2.php'>here</a> <"; } else { } $all_stuff = "<b>Admin name</b>:<b><font face='Tahoma' size='3'> $username</font></b> <hr size=1> <br>Adm Pass: $password <br>Adm email: $email"; if($i % $tblWidth ){ echo "<td align='center' valign='top' bgcolor='#F2F2F2'>$all_stuff</td>"; }else{ //else then print column number 2 etc for the next loop. echo "<tr></tr>"; echo "<td align='center' cellpadding='10' valign='top' bgcolor='#F2F2F2'>$all_stuff</td>"; } //add only 1 for the loop ($i). $i++; Link to comment https://forums.phpfreaks.com/topic/169627-let-only-1-register-user-see-a-link/ Share on other sites More sharing options...
perrij3 Posted August 10, 2009 Share Posted August 10, 2009 Give something like this a try, I broke your code down so it's easier to read. I took out a bunch of the echos and prints and just used HTML code instead. <?php if(mysql_num_rows($sql) > 0){ // Loop through the results while($row = mysql_fetch_array($sql)){ $username = $row['username']; $password = $row['password']; $email = $row['email']; if ($username == lady1) { ?> click, click > <a href='crew2.php'>here</a> < <?php } else { } ?> <b>Admin name</b>:<b><font face='Tahoma' size='3'> $username</font></b> <hr size=1> <br>Adm Pass: $password <br>Adm email: $email <?php if($i % $tblWidth ){ ?> <td align='center' valign='top' bgcolor='#F2F2F2'><?php echo $all_stuff; ?></td> <?php }else{ //else then print column number 2 etc for the next loop. ?> </tr><tr> <td align='center' cellpadding='10' valign='top' bgcolor='#F2F2F2'><?php echo $all_stuff; ?></td> <?php } //add only 1 for the loop ($i). $i++; ?> I don't know how you have your table set up, I'm assuming that you have omitted some of that code. Link to comment https://forums.phpfreaks.com/topic/169627-let-only-1-register-user-see-a-link/#findComment-894921 Share on other sites More sharing options...
RussellReal Posted August 10, 2009 Share Posted August 10, 2009 #1 you're trying to compare 'lady1' as a string NOT a constant to the $username variable which means you should encase that string with quotes.. #2 when a user logs in you should store their username and other often used information in a session... so if you do store them in a session if ($_SESSION['username'] == 'lady1') { } Link to comment https://forums.phpfreaks.com/topic/169627-let-only-1-register-user-see-a-link/#findComment-894923 Share on other sites More sharing options...
neif_mamdouh Posted August 10, 2009 Share Posted August 10, 2009 Try this if ($_SESSION['MM_Username'] = "your_username") { ?> MESSAGE TO BE DISPLAYED <?php } ?> Link to comment https://forums.phpfreaks.com/topic/169627-let-only-1-register-user-see-a-link/#findComment-894924 Share on other sites More sharing options...
chanfuterboy Posted August 10, 2009 Author Share Posted August 10, 2009 hi, if i try the session one: if ($_SESSION['username'] == 'lady1') { } click, click > <a href='crew2.php'>here</a> < all user display the link text 3 times now. in that case what is the conclusion? Link to comment https://forums.phpfreaks.com/topic/169627-let-only-1-register-user-see-a-link/#findComment-894946 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.