Hi there,
New issue coming up after that iteration that I hope you can help me with.
Here's what I'm doing...
I'm pulling phone number data from a MySQL database and then, row by row, I am displaying it within a dropdown (Phone Type - for example, "work", "home", etc) and then next to it, a Phone Number that is associated is displayed in a text-box that is editable.
What I want to be able to do is this:
If there are say, 4 phone numbers listed, each one will look like this...
Dropdown Textbox
[WORK] [Phone Number ]
[HOME] [Phone Number ]
[OTHER] [Phone Number ]
[PAGER] [Phone Number ]
Here is HOW I am doing this right now...
<?php
// pull the PHONE info
$phone_pull = "SELECT * " .
"FROM PHONE " .
"WHERE CONTACT_FK=" . $_GET['contact_id'];
$pulled_phone = mysql_query($phone_pull,$conn) or die('Could not perform the search on phone; ' . mysql_error());
//to iterate through the "PHONE TYPE" options I have to create an array and then compare to it
$phone_type = array(
"WORK"=>"Work",
"HOME"=>"Home",
"CELL"=>"Cell",
"PAGER"=>"Pager",
"FAX"=>"Fax",
"OTHER"=>"Other"
);
//Now, run through each row and display the desired fields for each row produced.
while ($phone_row = mysql_fetch_array($pulled_phone, MYSQL_ASSOC))
{
echo '<tr>';
echo '<td noWrap width="50%" align="right" valign="top"><FONT face="Tahoma" color="#000000" size="2">';
// iterate through the CONTACT TYPE dropdown using the $phone_type array.
echo "<P align=\"right\"><select id=\"phone_type\" name=\"phone_type\" tabindex=\"36\">\n";
foreach ($phone_type as $phone_type4db => $phone_typename)
{
echo "<option value='$phone_type4db'";
echo ($phone_type4db == $phone_row['PHONE_TYPE']) ? " selected" : "";
echo ">$phone_typename</option>\n";
}
echo "</select>\n";
echo '</FONT></td>';
echo '<td noWrap width="50%" align="left" valign="top"><FONT face="Tahoma" color="#000000" size="2">';
echo '<P align="left">';
?>
<INPUT type="text" id="phone_num" name="phone_num" maxLength="50" size="20" tabindex="37" value="<?php echo $phone_row['PHONE_NUM']; ?>">
<?php
echo '</FONT></P></td>';
echo '</tr>';
}
?>
My question is this: With this method, Since the rows are simply run through...how will I be able to take any data that the user updates (for example, changing the "TYPE" or changing the phone number for any one of those listed, and then using a MySQL UPDATE, put the new information in the database with the associated record?
Thanks once again from a grateful newbie...
-tryxxter