Jump to content

[php] mysql_fetch_array problem


JonnySnip3r

Recommended Posts

Hey guys i have a query that select from multiple tables and works fine however i have the same field name in each table called::

 

member_id

 

but i want to select specifically the member_id from table1 do i need to change the name when i loop through them? i really dont want to do that but if it confuses php unless is there a way when doin a while loop i specify what table i want it from?

 

while($row = mysql_fetch_array($query)){
    $member_id = $row['member_id'];
}

Link to comment
Share on other sites

hey dude here is the problem::

 

$friend_query = mysql_query("SELECT * FROM member_friends WHERE my_id = '$my_id'");
	while($row = mysql_fetch_array($friend_query)){
		$friend_id = $row['friend_id'];

		$sql = mysql_query("SELECT a.*,b.* FROM member_topics as a, member_friends as b WHERE (a.member_id = b.my_id) 
												AND ((b.friend_id = '$friend_id') AND b.my_id = '$my_id') ORDER BY a.message_id DESC");

		while($row = mysql_fetch_array($sql)){
			$message_id = $row['message_id'];
			$member_id = $row['member_id'];
			$message_contents = $row['message_contents'];
			$message_date = $row['message_date'];
			$message_type = $row['message_type'];
			$message_reported = $row['message_reported'];

			$mem_image = get_member_image_from_member_id($member_id);
			$member_name = get_member_name_from_member_id($member_id);

			// Clean::
			$message_cleaned = bad_word_filter($message_contents,$my_id,$message_id);

			echo "<div id=\"message_section\">";
			echo "<img src='profile/images/$mem_image' alt='Message Image' />";
			echo "<h5><a href='http://mysite.com/$member_name'>$member_name</a> - $message_date</h5>";
			echo "<p>$message_cleaned</p>";
			echo "</div><!-- end message_section -->";
}
}

 

when i loop i dont think its passing the new value into the while loop hence the reason the query isnt working is this correct? or is there a easy way i always seem to do the long way haha

 

Thanks!!!

 

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.