0

Hello all, i dont know how to fix this i made allot of forms but never with select option, what i want is to post
the select option and to update database. here is the script could somebody explain me how to change this

echo '<tr><td><select>';
echo '<option value="volvo" name=uvolvo>Volvo</option>';
echo '<option value="saab" name=usaab>Saab</option>';
echo '<option value="opel" name=uopel>Opel</option>';
echo '<option value="audi" name=audi>Audi</option>';
echo '</tr></td></select>';

And do i need to change also this

$AddQuery = "INSERT INTO producten (Product, Item, Description, Extra, Valuta, Price, Nummer)

in to this

$AddQuery = "INSERT INTO producten (Product, Item, Description, Extra, Valuta, Price, Nummer, Volvo, Saab, Opel, Audi )

Any help is welcome.

if(isset($_POST['add'])){
$AddQuery = "INSERT INTO producten (Product, Item, Description, Extra, Valuta, Price, Nummer) VALUES ('$_POST[uproduct]','$_POST[uitem]','$_POST[udescription]','$_POST[uextra]','$_POST[uvaluta]','$_POST[uprice]','$_POST[unummer]')";         
mysql_query($AddQuery, $con);
};

$sql = "SELECT * FROM producten";
$myData = mysql_query($sql,$con);

while($record = mysql_fetch_array($myData))
echo '<table border="0" cellpadding="0" cellspacing="0"  id="id-form">';
echo '<form action=add-product.php method=post>';

echo '<tr>';
echo '<th valign="top">Product name:</th>';
echo '<td><input type=text class="inp-form" name=uproduct></td>';
echo '<td></td></tr>';

echo '<tr>';
echo '<th valign="top">Item:</th>';
echo '<td><input type=text class="inp-form" name=uitem></td>';
echo '<td></td></tr>';


echo '<tr>';
echo '<th valign="top">Extra</th>';
echo '<td><input type=text class="inp-form" name=uextra></td>';
echo '<td></td></tr>';

echo '<tr>';
echo '<th valign="top">Valuta</th>';
echo '<td><input type=text class="inp-form" name=uvaluta></td>';
echo '<td></td></tr>';

echo '<tr>';
echo '<th valign="top">Price</th>';
echo '<td><input type=text class="inp-form" name=uprice></td>';
echo '<td></td></tr>';

echo '<tr>';
echo '<th valign="top">Nummer</th>';
echo '<td><input type=text class="inp-form" name=unummer></td>';
echo '<td></td></tr>';

echo '<tr><td><select>';
echo '<option value="volvo" name=uvolvo>Volvo</option>';
echo '<option value="saab" name=usaab>Saab</option>';
echo '<option value="opel" name=uopel>Opel</option>';
echo '<option value="audi" name=audi>Audi</option>';
echo '</tr></td></select>';

echo '<tr>';
echo '<th valign="top">Description</th>';
echo '<td><textarea rows="" cols="" class="form-textarea" name=udescription></textarea></td>';
echo '<td></td></tr>';

echo '<tr>
    <th>Image 1:</th>
    <td><input class="file file_1" style="display: inline; width: 300px;"><div style="width: 78px; height: 29px; background-image: url(http://localhost/controlpannel/images/forms/upload_file.gif); display: inline; position: absolute; overflow: hidden; background-position: 100% 50%; background-repeat: no-repeat no-repeat;"><input type="file" class="file_1" style="position: relative; height: 29px; width: 300px; display: inline; cursor: pointer; opacity: 0; margin-left: -222px;"></div></td>
    <td>
    <div class="bubble-left"></div>
    <div class="bubble-inner">JPEG, GIF 5MB max per image</div>
    <div class="bubble-right"></div>
    </td>
    </tr>';


echo '<td valign="top">';
echo '<td>' . '<input type=submit class="form-submit" name=add value=' . ' </td>';
echo '</td></tr>';

echo '</form>';
echo '</table>';
mysql_close($con);

Thanks in advance !!

Edited by games1124u

2
Contributors
1
Reply
20
Views
4 Years
Discussion Span
Last Post by diafol
0

This is not the way to do it. If you change the cars in the select,it means you have to change your DB table. That's just not practical.

You should be looking to create a table like this:

Product, Item, Description, Extra, Valuta, Price, Nummer, Car_make_id

With another related table for car_make:

Car_makes

car_make_id
car_make_name

You then just need to query this table to build your html select, e.g.

SELECT * FROM car_makes

while(...){
    $options.= "<option value='{$r['car_make_id']}'">{$r['car_make_name']}</option>";
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.