Jump to content

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

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.