ansonb
03-13-2012, 05:23 AM
I have a form that selects data from database table 1 and then on submission of the form inserts them into table 2. I need help with seperating the variables before insertion in the table 2.
Here is my code:
$query4 = "SELECT artist_id,artist_name FROM artists ORDER BY artist_name";
$result4 = mysql_query($query4) or die(mysql_error());
echo "<select name='artist'>";
while($row=mysql_fetch_array($result4))
{
echo "<option value='". $row['artist_id'] . $row['artist_name'] ."'>". $row['artist_name'] ."</option>";
}
echo "</select>
As you can see I select artist_name and artist_id from seperate columns in table 1. The results are:
<option value='13Adam Fielding'>Adam Fielding</option>
I need the artist_id and artist_name get passed into table 2 in seperate columns just as they were selected from the table 1.
How do I do this ??
Thanks.
Here is my code:
$query4 = "SELECT artist_id,artist_name FROM artists ORDER BY artist_name";
$result4 = mysql_query($query4) or die(mysql_error());
echo "<select name='artist'>";
while($row=mysql_fetch_array($result4))
{
echo "<option value='". $row['artist_id'] . $row['artist_name'] ."'>". $row['artist_name'] ."</option>";
}
echo "</select>
As you can see I select artist_name and artist_id from seperate columns in table 1. The results are:
<option value='13Adam Fielding'>Adam Fielding</option>
I need the artist_id and artist_name get passed into table 2 in seperate columns just as they were selected from the table 1.
How do I do this ??
Thanks.