sofia403 Posted May 28, 2011 Share Posted May 28, 2011 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>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/237689-form-values-2/ Share on other sites More sharing options...
paul2010 Posted May 28, 2011 Share Posted May 28, 2011 echo $row['ApplicationStatus']; insert where you want the date to be shown. Quote Link to comment https://forums.phpfreaks.com/topic/237689-form-values-2/#findComment-1221447 Share on other sites More sharing options...
sofia403 Posted May 28, 2011 Author Share Posted May 28, 2011 hi, wouldnt it just select the values of the Application status? I have no problem displaying and identifying ApplicationStatus, what i need is for a another column that has Dates in it to have similar query that finds out which entry is already in db and then display it. Quote Link to comment https://forums.phpfreaks.com/topic/237689-form-values-2/#findComment-1221448 Share on other sites More sharing options...
mikesta707 Posted May 28, 2011 Share Posted May 28, 2011 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']}"; Quote Link to comment https://forums.phpfreaks.com/topic/237689-form-values-2/#findComment-1221560 Share on other sites More sharing options...
sofia403 Posted May 28, 2011 Author Share Posted May 28, 2011 Great! I got it, thanks again mikesta. Quote Link to comment https://forums.phpfreaks.com/topic/237689-form-values-2/#findComment-1221581 Share on other sites More sharing options...
mikesta707 Posted May 28, 2011 Share Posted May 28, 2011 No problem. Remember, if your topic is solved, you can click the "topic solved" button at the bottom of the thread Quote Link to comment https://forums.phpfreaks.com/topic/237689-form-values-2/#findComment-1221586 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.