Jump to content

Input boxes from a database


xionhack

Recommended Posts

Hello. I need help with something I am doing. Lets say that I have to tables "member" and "color", the "member" has "member_id, first_name, last_name"  the "color" table has "color_id, color".

 

What I want is to call all the members that dont have a color assigned, and next each name a select box with all the colors, and when they select one and press a button the "color" field in the "member" table will be updated with the color selected for that particular member. Please let me know if you understand! thanks!

Link to comment
Share on other sites

you mean something like this?

<?php
$sql = "SELECT * FROM color";
$result = mysql_query($sql);
$selectColor = "<select name='selectColor'>";
while ($color = mysql_fetch_array($result)){
$selectColor .= "<option value='".$color['color_id']."'>".$color['color']."</option>";
}
$selectColor .= "</select>";

unset($result, $color);

$sql = "SELECT * FROM member WHERE color IS NULL";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)){
echo $row['first_name'], " ", $row['last_name'], ": ", $selectColor, "<br />";
}
?>

 

note: this is not working code! no mysql_connect(), no form creation. edit it to suit your needs.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.