Jump to content

Recommended Posts

Hi, mates!

 

The following query acts very strange,  it returns only 1 result instead of X...

I might be doing it wrong somewhere :shrug:

<?php
$query = "SELECT ul_user_id, ul_nick, ul_region_id, up_user_id, up_instrument FROM prn_user_list, prn_user_profile WHERE
		(prn_user_list.ul_region_id='". $region ."') 
		AND (prn_user_list.ul_user_id = prn_user_profile.up_user_id) 
		AND (prn_user_profile.up_instrument = '". $instrument ."')";	
$result = mysql_query($query) or die(mysql_error());	
	while($row = mysql_fetch_array($result)) {
		echo "User: ". 		$row['ul_nick'] 		."<br />";
		echo "Region: ". 		$row['ul_region_id'] 	."<br /><br />";
	}
}
?>

 

Tnx in advance! :shy:

Link to comment
https://forums.phpfreaks.com/topic/166789-solved-mysql-query-problem/
Share on other sites

Hi

 

Looks fine at first glance. What happens if you remove the checks for region and instrument?

 

$query = "SELECT ul_user_id, ul_nick, ul_region_id, up_user_id, up_instrument FROM prn_user_list INNER JOIN prn_user_profile

ON prn_user_list.ul_user_id = prn_user_profile.up_user_id";

 

All the best

 

Keith

Tnx for reply :)

 

Worked fine, listing significant amount of users. Also worked when I added

 WHERE prn_user_profile.up_instrument='". $instrument ."' 

at the end, but not when added

 WHERE prn_user_profile.up_instrument='". $instrument ."' AND prn_user_list.ul_region_id = '". $region ."'

 

Any way that could be fixed? :(

Oh, I noticed that very few members actually filled out required data (region and instrument from their profiles)!

That's why query was returning weird results :D :D

 

Thank you for your time and effort in solving this "issue", kickstart! :)

 

King regards!!! ;D

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.