Jump to content

Select Lists


-Karl-

Recommended Posts

I have my code

			$url = $arr[url];
		$clan = mysql_query("SELECT * FROM `clan` WHERE `url` = '$url'");
		$editmembers = mysql_query("SELECT * FROM `members` WHERE `clanurl` = '$clan'");
		$i = 0;
		while($result_ar = mysql_fetch_assoc($editmembers)){
		echo "<option value='{$result_ar['username']}'>{$result_ar['username']}</option>";
		$i+=1;
		}

 

However it doesn't work.

 

When I echo $clan I recieve:

Resource id #16

 

and when I echo $editmembers I recieve:

Resource id #17

 

Any ideas what's wrong?

Link to comment
https://forums.phpfreaks.com/topic/198904-select-lists/
Share on other sites

Im kind of unsure what you are trying to achieve.

 

But first: You should use apostrophe's when getting data from array:

$arr['url'] instead of $arr;

Unless ofc url is defined.

 

And you get that because those are resource id's. IF you wish to fetch data from them you need to use specific functions.

 

For example, try this to give you some idea:

$url = $arr['url'];
$clan = mysql_query("SELECT * FROM `clan` WHERE `url` = '$url'");
$test = mysql_fetch_array($clan);
echo '<pre>';
print_r($test);
echo '</pre>';

 

Link to comment
https://forums.phpfreaks.com/topic/198904-select-lists/#findComment-1044072
Share on other sites

Im kind of unsure what you are trying to achieve.

 

But first: You should use apostrophe's when getting data from array:

$arr['url'] instead of $arr;

Unless ofc url is defined.

 

And you get that because those are resource id's. IF you wish to fetch data from them you need to use specific functions.

 

For example, try this to give you some idea:

$url = $arr['url'];
$clan = mysql_query("SELECT * FROM `clan` WHERE `url` = '$url'");
$test = mysql_fetch_array($clan);
echo '<pre>';
print_r($test);
echo '</pre>';

 

 

I would also suggest using brackets when using variables inside strings like this:

instead of $hey = 'my name is ' . $name; and $hey = "my name is $name", go like this: "my name is {$name}".

 

edit: oops double :/

Link to comment
https://forums.phpfreaks.com/topic/198904-select-lists/#findComment-1044073
Share on other sites

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.