View Full Version : PHP MySql Select Box Help

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'>";

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 ??


03-13-2012, 06:15 AM
Duplicating data in multiple tables is NOT a good idea.

What does table 2 represent (how is it used later)?

03-13-2012, 06:30 AM
Table 1 contains all artist information. Website, bio, facebook page, graphic, etc.
I use this info for individual artist pages on my site.

Table 2 contains info on which artists are heard on a particular show. show id, track number, artist id, artist name, and song.

The only two columns they have in common are artist_id and artist_name.

I link to individual artist pages from the page that shows what artists play on a certain show. I need the name and artist id for building the links.

03-14-2012, 11:06 PM
Please Help