I have PHP script that I use for new entry and edit entry, inside the form I have query combo (combo values querying from other table), my problem is how make the default value of my combo to actual value on the edit table instead on picking the first value on my query.
For instance I have query combo CAT, DOG, RABBIT.
1st time entry user choose RABBIT and then save, then user go back to edit page this time the combo will display the last value which is RABBIT instead of CAT as first choice. I hope Im explaining this very well let me know if you need more info.
Expand|Select|Wrap|Line Numbers
- echo '<tr><td><b>How was event lead generated:</b></td>';
- $res=mysql_query("select lead from tblgenerated");
- if(mysql_num_rows($res)==0){
- echo "there is no data in table..";
- } else {
- echo ' <td width="100%"><select name="lead" id="lead">';
- for($i=0;$i<mysql_num_rows($res);$i++) {
- $row=mysql_fetch_assoc($res);
- echo"<option value=$row[lead]";
- if($Var==$row[lead])
- echo 'selected';
- echo ">$row[lead]</option>";
- }
- echo
- "</select><br></tr></td>";
- }
Expand|Select|Wrap|Line Numbers
- <td colspan="2"><input type="text" name="location" ' . 'id="entry_location"
- size="85" value="' . htmlspecialchars ( $location ) . '" /> </td>
DM