Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Help a PHP noob

Name: Anonymous 2013-08-12 10:30

Hi guys. Just started tinkering in PHP.
I made a form with a dropdown box which get populated from a MYSQL database. like this:

<form name="form" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">

<?php
echo  "<select name='search' onChange='this.form.submit()'>";
    while ($row = mysql_fetch_array($result)) {
        echo "<option value='" . $row['ID'] . "'>" . $row['ID'] . " </option>";
}
?>


This fetches an ID and fills the rest of the form with DB data like this:

$search=$_POST['search'];

$data = 'SELECT * FROM `tlbintake` WHERE `ID` = "'.$search.'"';
  $query = mysql_query($data) or die("Couldn't execute query. ". mysql_error());
  $data2 = mysql_fetch_array($query);


Everything works correctly but after selecting an ID from the dropdownbox it fills in all the data correctly but it resets the ID to the "first" ID in the list.

How can I make it show the correct ID in stead of the first one?

Name: Anonymous 2013-08-12 11:50

>>1
Just started tinkering in PHP.
Drop it like it's hot.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List