plznty Posted December 27, 2008 Share Posted December 27, 2008 <?php include("include/data.php"); if ($_COOKIE[user] == ($username) && $_COOKIE[pass] == md5($password)) { include("include/config.php"); $query="SELECT * FROM logs"; $result=mysql_query($query); $num=mysql_num_rows($result); mysql_close(); echo "<center><font color='#FFFFFF'><b>Logs</b><p>"; $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $username=mysql_result($result,$i,"username"); $password=mysql_result($result,$i,"password"); $logger=mysql_result($result,$i,"logger"); echo "Username: $username<br>Password: $password<br>Logged by: $logger<br>"; $i++; } }else{ echo '<META HTTP-EQUIV="Refresh" CONTENT="0; URL=index.php">'; } ?> I want it so that if $logger is equal to the login username then display. If not do not display anything. Quote Link to comment https://forums.phpfreaks.com/topic/138578-solved-help-me-with-php-sql/ Share on other sites More sharing options...
MadTechie Posted December 27, 2008 Share Posted December 27, 2008 HUmmmmmm you want IF $logger is equal to (==) the $username then display(echo)! So if($logger==$username) { echo "something!"; } Quote Link to comment https://forums.phpfreaks.com/topic/138578-solved-help-me-with-php-sql/#findComment-724588 Share on other sites More sharing options...
plznty Posted December 27, 2008 Author Share Posted December 27, 2008 I fort that would work but now it only posts "something!" if the logger is not the username. Could someone add me on msn or something so i can discuss this, ill pay a small fee Quote Link to comment https://forums.phpfreaks.com/topic/138578-solved-help-me-with-php-sql/#findComment-724595 Share on other sites More sharing options...
MadTechie Posted December 27, 2008 Share Posted December 27, 2008 This code is cleaner no point finding a all records if you only want to display some <?php include("include/data.php"); if ($_COOKIE['user'] == ($username) && $_COOKIE['pass'] == md5($password)) { include("include/config.php"); $query="SELECT * FROM logs WHERE username=logger"; $result=mysql_query($query); $num=mysql_num_rows($result); echo "<center><font color='#FFFFFF'><b>Logs</b><p>"; $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $username=mysql_result($result,$i,"username"); $password=mysql_result($result,$i,"password"); $logger=mysql_result($result,$i,"logger"); echo "Username: $username<br>Password: $password<br>Logged by: $logger<br>"; $i++; } mysql_close(); }else{ echo '<META HTTP-EQUIV="Refresh" CONTENT="0; URL=index.php">'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/138578-solved-help-me-with-php-sql/#findComment-724597 Share on other sites More sharing options...
plznty Posted December 27, 2008 Author Share Posted December 27, 2008 <?php include("include/data.php"); if ($_COOKIE['user'] == ($username) && $_COOKIE['pass'] == md5($password)) { include("include/config.php"); $query="SELECT * FROM logs WHERE username=logger"; $result=mysql_query($query); $num=mysql_num_rows($result); echo "<center><font color='#FFFFFF'><b>Logs</b><p>"; $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $username=mysql_result($result,$i,"username"); $password=mysql_result($result,$i,"password"); $logger=mysql_result($result,$i,"logger"); echo "Username: $username<br>Password: $password<br>Logged by: $logger<br>"; $i++; } mysql_close(); }else{ echo '<META HTTP-EQUIV="Refresh" CONTENT="0; URL=index.php">'; } ?> I need it to display the logs on the database where $logger is equal to the login username. Quote Link to comment https://forums.phpfreaks.com/topic/138578-solved-help-me-with-php-sql/#findComment-724599 Share on other sites More sharing options...
MadTechie Posted December 27, 2008 Share Posted December 27, 2008 change $query="SELECT * FROM logs WHERE username=logger"; to $query="SELECT * FROM logs WHERE logger='$username' "; Quote Link to comment https://forums.phpfreaks.com/topic/138578-solved-help-me-with-php-sql/#findComment-724644 Share on other sites More sharing options...
plznty Posted December 27, 2008 Author Share Posted December 27, 2008 change $query="SELECT * FROM logs WHERE username=logger"; to $query="SELECT * FROM logs WHERE logger='$username' "; That looks about right, but i get an error Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\web\PHISHER-V2\phisher\admin\logs.php on line 8 Help? Quote Link to comment https://forums.phpfreaks.com/topic/138578-solved-help-me-with-php-sql/#findComment-724680 Share on other sites More sharing options...
JasonLewis Posted December 27, 2008 Share Posted December 27, 2008 Make this: $result=mysql_query($query); This: $result=mysql_query($query) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/138578-solved-help-me-with-php-sql/#findComment-724686 Share on other sites More sharing options...
plznty Posted December 28, 2008 Author Share Posted December 28, 2008 Okay it works now! Thanks everybody. Quote Link to comment https://forums.phpfreaks.com/topic/138578-solved-help-me-with-php-sql/#findComment-724819 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.