Jump to content

[SOLVED] Echo WHERE IF


markvaughn2006

Recommended Posts

This one has really got me stumped...

I need to display everybody with the location =$userlocation and wanted_lvl=1. But.. I need to also somehow include an IF that will check a field from the mysql query against a field in the logged in users row..

 

So what this boils down to is I need to display everyone who's location equals $userlocation and wanted_lvl equals 1 but only show the people that who have less "stealth" than the logged in user has "vision". So it would show some people who have a lower stealth than your vision but it wouldn't show the people that have a higher stealth than your vision.

 

<?php

$result = mysql_query("SELECT user_name, location_message FROM users_tbl

WHERE location='$userlocation' AND wanted_lvl='1'")

  or die(mysql_error());

while ($row = mysql_fetch_array($result)) {

  echo '<form target="actions" method="post" action="includes/report.php"><input type="submit" value="Report" /><font color="red">'.$row['user_name'].'</font><input type="hidden" name="reported" value="'.$row['user_name'].'" /></form>';

  }

?>

 

 

Thanks for any help!! Sorry if this in the wrong forum, but it's more the php than the mysql i'm having a problem with

Link to comment
Share on other sites

If I'm understanding your correctly this can all, and should all be done within the query itself.

 

eg.

 

$result = mysql_query("SELECT user_name, location_message FROM users_tbl
WHERE location='$userlocation' AND wanted_lvl='1' AND stealth < '$uservision'");

Where $uservision contains the vision value for the current user.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.