Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Apr 26th, 2006, 1:18 PM   #1
piercy
Programmer
 
Join Date: Apr 2006
Posts: 35
Rep Power: 0 piercy is on a distinguished road
mysql table view require()or suggestions.

i am trying to create a form that will show a database table in the required format eg. name a-z or email a-z etc.. i would like this so that when the page loads up the table is displayed and then by selecting a drop down menu. you can change the format. so far i have been totally confused by doing this on one page. so i am trying to do it over 2(if you get what i mean).
This is my form:
<html>


<body>

<form action="table.php" name="form" method="post">
<select name="view">
<option value="fullname">fullname a-z
<option value="email"> email a-z
</select>
<input type="submit" name="submit">
</form>

</body>
</html>

and this is the php code i have to interpret the form.
$view = $_POST["view"];
print("$view");

$db = mysql_connect('localhost', 'guest', 'password');
mysql_select_db('test',$db); 
$result = mysql_query('SELECT * FROM messages  ORDER BY $view DESC',$db); 
echo '<TABLE border="1">'; 
echo '<TR><TD><B>Full Name</B></td><TD><B>Email Address</B></td><TD><B>Date and time</B></td><TD><B>Message</td></B></TR>';
while($myrow = mysql_fetch_array($result)) 
{ 
echo '<TR><TD>'; 
echo $myrow['fullname']; 
echo "<TD>"; 
echo $myrow['emailaddress'];  
echo "<TD>"; 
echo $myrow['date']; 
echo "<TD>"; 
echo $myrow['message']; 
} 
echo '</TABLE>';
?>
i did a test to check the variable $view was recieving the right info from the form and it seems fine. i just cant seem to get it displaying the table once it is formated. it just displays it as it was.

please help me sort this one out or even better help me create a code thats all on one page
__________________
this forum rules you guys are great!
thanks to all who help
piercy
piercy is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:58 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC