Jump to content

form values 2


sofia403

Recommended Posts

Hi, how would i display the date that is already in db and was submitted by user when he logs in to their profile?

That code below works for the values like 'approved' 'denied' so on, but how would i do same for a date? thank you.

 

<?php
include('config.php');
$uname=$_SESSION['username'];
if($_SESSION['username']){
$sql="SELECT ApplicationStatus FROM table1 WHERE uname='$uname'";
$result=mysql_query($sql);
$row = mysql_fetch_array($result);}
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
https://forums.phpfreaks.com/topic/237689-form-values-2/
Share on other sites

Oh hey I remember you.

 

Anyways, you are going to do something similar to what you already have. In MySQL queries, you can select multiple things at once. So you don't even have to do another query, but modify your existing one to get the other information you need. For example

//your original query whtat just gets ApplicationStatus
$sql="SELECT ApplicationStatus FROM table1 WHERE uname='$uname'";
//now if we want the column with date information in it, we just select it also by adding it after ApplicationStatus, in a comma seperate list.
//so for example, if the column you are after is named DateInfo, we do
$sql="SELECT ApplicationStatus, DateInfo FROM table1 WHERE uname='$uname'";

 

once you have selected it, its just a matter of displaying it wherever you need using the $row array and echo. So for example, if you simply wanted to display it after your select input

...
$row = mysql_fetch_array($result);}
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>';
echo "Date Information : {$row['DateInfo']}";

Link to comment
https://forums.phpfreaks.com/topic/237689-form-values-2/#findComment-1221560
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.