dcornu Posted October 28, 2009 Share Posted October 28, 2009 Hi, I'm trying to modify the following in order to make the output table sorted alphabetically according to $event_name but so far have not succeeded. Any pointers? function display_all_events(){ global $wpdb; $events_detail_tbl = get_option('events_detail_tbl'); $curdate = date("Y-m-d"); $paypal_cur = get_option('paypal_cur'); $sql = "SELECT * FROM ". $events_detail_tbl; $result = mysql_query ($sql); echo "<table width = '100%'>"; while ($row = mysql_fetch_assoc ($result)) { $event_id = $row['id']; $event_name=$row['event_name']; $event_identifier=$row['event_identifier']; $cost=$row['event_cost']; $active=$row['is_active']; echo "<tr><td width='100%'>".$event_name." - ".$paypal_cur." ".$cost."</p><hr></td><td>"; echo "<form name='form' method='post' action='".$_SERVER['REQUEST_URI']."'>"; echo "<input type='hidden' name='regevent_action' value='register'>"; echo "<input type='hidden' name='event_id' value='".$row['id']."'>"; echo "<input type='SUBMIT' value='REGISTER'></form></td></tr>"; } echo "</table>"; } Am relatively new to php so please excuse me for posting stuff that may seem obvious to others but I really need to sort this out as the workaround is very time consuming... Thanks. Link to comment https://forums.phpfreaks.com/topic/179315-solved-table-sorting/ Share on other sites More sharing options...
seanlim Posted October 28, 2009 Share Posted October 28, 2009 try: $sql = "SELECT * FROM ". $events_detail_tbl ." ORDER BY event_name ASC"; Link to comment https://forums.phpfreaks.com/topic/179315-solved-table-sorting/#findComment-946083 Share on other sites More sharing options...
dcornu Posted October 28, 2009 Author Share Posted October 28, 2009 Works! Thanks a million. Saved me a lot of time... Link to comment https://forums.phpfreaks.com/topic/179315-solved-table-sorting/#findComment-946086 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.