Jump to content

Match values in an array


brob

Recommended Posts

Hi I want to add the data from this query into an array

 

$result=mysql_query("select start_time, end_time, room_id, name, description, mobile_no from mrbs_entry, mrbs_tel where mrbs_entry.room_id = mrbs_tel.contact_id and start_time >= '$today_start' and end_time < '$today_end'");  
while ($i = mysql_fetch_row($result)) 
{  

 

there isn't a primary key but the field I want to match against is the room_id.

 

If there are more than 2 room_id's I want t pull out their information.

 

Can you help?

 

 

Link to comment
Share on other sites

$result=mysql_query("select start_time, end_time, room_id, name, description, mobile_no from mrbs_entry, mrbs_tel where mrbs_entry.room_id = mrbs_tel.contact_id and start_time >= '$today_start' and end_time < '$today_end'"); 

while ($row = mysql_fetch_array($result))

echo $row[0]

}

 

use mysql_fetch_array instead of mysql_fetch_row, the mysql query should do the rest.

 

 

Link to comment
Share on other sites

brob, you are using a lot of generic terms that could mean many things:

 

"Hi I don't want to get rid of the duplicates i want to identify them and merge the results."

Soa re you sayting if there are two records with the same id you want to have only one record with some data fields combined?

 

"If there are more than 2 room_id's I want t pull out their information."

Pull out to where and do what with it?

 

How about you show us: 1) Your current query and 2) An example of the data from two records and how you want to convert/display it.

 

I'm thinking there is probably a very easy solution that does not require a new query or even an array, but you are not giving enough information.

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.