newbie_07 Posted May 10, 2008 Share Posted May 10, 2008 Hello to all. i am new to php. I have the following code: $sql = "SELECT client_info.client_id, client_info.f_name, client_info.l_name, services.service_name From client_info, services"; $res = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_assoc($res)){ $c_id = $row['client_id']; //$s_name = $row['service_name']; $s_names .="<option>$row[service_name]</option>"; $c_names .="<option value=$c_id>".$row['f_name']." ".$row['l_name']."</option>"; } I am displaying client_names and services names in a listbox. All are coming but they are appearing multiple times. I don't know why? Please help Quote Link to comment Share on other sites More sharing options...
xenophobia Posted May 10, 2008 Share Posted May 10, 2008 Your sql did not include the joining statement... Try these: SELECT client_info.client_id, client_info.f_name, client_info.l_name, services.service_name FROM client_info, services WHERE client_info.service_id = services.service_id I am just make a guess that your client_info had a field named service_id(foreign key) which linked to the services table with a same primary key field name. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.