Jump to content

record id instead of data


nec9716

Recommended Posts

//Get driver1 post information.

if(isset($_POST['DropDown1']))

$driver1 = $_POST['DropDown1'];

else

$driver1 = 1;

 

//Generate and run the query to populate the driver1 listbox. (driver1)

$query = "SELECT id, name FROM pilote";

$result = mysql_query($query);

 

//--Create 1 listbox.

echo '<b>Driver # 1:</b><br/>';

echo '<select name="driver1" size="1" onchange="setItemListBox()">';

while($row = mysql_fetch_array($result, MYSQL_NUM))

{

if($row[0] == $driver1)

echo '<option value="' . $row[0] . '" selected>' . $row[1] . '</option>';

else

echo '<option value="' . $row[0] . '">' . $row[1] . '</option>';

}

echo '</select>';

//--End 1 listbox

 

 

when I select something from the list box the ID is ( which is my first column ) is write in the DB

but I want to write what I'm select ( in this case ) my second column of my DB?

 

I can't understand what I have to change in this script to allow me to do so

thank you

 

 

Link to comment
https://forums.phpfreaks.com/topic/97089-record-id-instead-of-data/
Share on other sites

because it is a unique identifier for the record. you should try to compare integers instead of strings whenever possible. also, storing the id allows you to change the value of the string in one place without having to change it in every record. also, storing the id of the record takes less space. i'm sure there's more. it's just standard database procedure/normalization.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.