Jump to content

[SOLVED] MySQL Query problem


Nix

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.