Address book won't display name with correct phone number

So I am making an address book for my family website and trying to learn PHP at the same time. I am looking for a way to assign each child their phone numbers to display on the contact page. What I have written only displays one child’s name and all of the childrens phone numbers. What do I need to add here to make this fit my needs? I do have a seperate id for each child in mysql but can’t figure out how to use it when I’m already using a master_id to pull the information. I hope that makes sense. Please let me know if you need more info. Also thank you so much for helping me! Here is the section of script I am working with for this:

$get_c_tel = “select c_telephone from child_name where master_id = $_POST[sel_id]”;
$get_c_tel_res = mysql_query($get_c_tel);

if (mysql_num_rows($get_c_tel_res) > 0) {

	$display_block .= "<p><strong>$c_f_name Telephone:</strong><br>
	<ul>";
	
	while ($c_tel_info = mysql_fetch_array($get_c_tel_res)) {
		$c_tel_number = $c_tel_info[c_telephone];
		
		$display_block .= "<li>$c_tel_number";
	}
	
	$display_block .= "</ul>";
}

Don’t waist your time on this one anymore guys… A couple of tries with other ideas I figured it out. Here is my end result giving me perfectly what I needed:

$get_c_tel = “select c_f_name,c_telephone from child_name where
master_id = $_POST[sel_id]”;
$get_c_tel_res = mysql_query($get_c_tel);

if (mysql_num_rows($get_c_tel_res) > 0) {

	$display_block .= "<p><strong>Children Telephone:</strong><br>
	<ul>";
	
	while ($c_tel_info = mysql_fetch_array($get_c_tel_res)) {
		$c_tel_number = $c_tel_info[c_telephone];
		$c_first_name = $c_tel_info[c_f_name];
		
		$display_block .= "<li>$c_first_name - $c_tel_number";
	}
	
	$display_block .= "</ul>";
}
Sponsor our Newsletter | Privacy Policy | Terms of Service