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

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.