![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Programmer
Join Date: Apr 2006
Posts: 35
Rep Power: 0
![]() |
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>';
?>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 |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|