Jump to content

form values


sofia403

Recommended Posts

hi i was wondering how i can display the values for a form that already in db. users submitted a form and then when they log in to their profile they can change the value in a form, but the original value would show the one that they first submitted. makes sense?

 

at the moment its set as blank, how would i display the option value to the one in the db on their profile? thanks

 

<form name="test" method="post">
	<select name="ApplicationStatus">
	<option value="'">------</option>
	<option value="In process">In process</option>
	<option value="Withdrawn">Withdrawn</option>
                </select>

Link to comment
Share on other sites

Like so:

 

<?php
echo '<form name="test" method="post">
	<select name="ApplicationStatus">
	<option value="\'">------</option>
	<option value="In process" '.(($row['column1']=='In process')?'selected="selected"':'').'>In process</option>
	<option value="Withdrawn" '.(($row['column1']=='Withdrawn')?'selected="selected"':'').'>Withdrawn</option>
                </select>';
?>

Link to comment
Share on other sites

ok here it is

 

<?php
include('config.php');
$uname=$_SESSION['username'];
if($_SESSION['username']){
$sql="SELECT ApplicationStatus FROM table1 WHERE uname='$uname'";
$result=mysql_query($sql);}
echo '<form name="test" method="post">
	<select name="ApplicationStatus">
	<option value="">------</option>
	<option value="In process" '.(($row['column1']=='In process')?'selected="selected"':'').'>In process</option>
	<option value="Withdrawn" '.(($row['column1']=='Withdrawn')?'selected="selected"':'').'>Withdrawn</option>
                </select>';
?>

Link to comment
Share on other sites

Simple error.

 

you never define $row.

 

perhaps you mean to stick the following line after your $result=.. line

$row = mysql_fetch_array($result);

 

also, I don't know how your table is structured, but are you sure column1 is the correct column? Instead of column1 perhaps it should be ApplicationStatus

Link to comment
Share on other sites

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.