Ordering columns by date in php
<p>Below is the code im using:</p>

<p>Im trying to order the columns by date/time (not the time column, the actual date time i.e. timestamp) Does anyone have any suggestions on how to do this. </p>

<p>In addition to this im trying to switch the order values when the admin clicks "move up"/"move down" next to the row however i think that might be another question?</p>

<pre><code>&lt;?php
    session_start();
    if(!$_SESSION['admin']==1){
        header('Location: index.php');
    }


    $con = mysql_connect();
    if (!$con)
    {
        die('Could not connect: ' . mysql_error());
    }else{
        mysql_select_db("clickmediacouk_719504_db1",$con);
    }



    $day = trim(addslashes($_POST['day']));
    $time = trim(addslashes($_POST['time']));
    $class = trim(addslashes($_POST['class']));
    $location = trim(addslashes($_POST['location']));
    $cost = trim(addslashes($_POST['cost']));
    $info = trim(addslashes($_POST['info']));
    $class_order = trim(addslashes($_POST['order'])); //column used to 'order' the information

    if($day=="" or $time=="" or $class=="" or $location=="" or $cost=="" or $info==""){
        header('Location: admin.php?message=please fill out all fields!');
    }else{

        $query = "INSERT INTO `clickmediacouk_719504_db1`.`lisahall_timetable` (`day`, `time`, `class`, `location`, `cost`, `info`)
        VALUES ('".$day."', '".$time."', '".$class."', '".$location."', '".$cost."', '".$info."')";
        $update = mysql_query($query);



        header('Location: admin.php?success=true');
    }


?&gt;
</code></pre>

<p>It has been suggested that:</p>

<ul>
<li><p>Your SQL query should have ORDER BY class_order</p></li>
<li><p>Moving up UPDATE table set class_order = THE_ORDER_OF_THE_CLASS_ABOVE
WHERE id = TARGET_CLASS and UPDATE table set class_order =<br>
TARGET_CLASS_ORDER WHERE id = THE_CLASS_ABOVE</p>

<p>Moving down is the opposite of moving up</p></li>
</ul>

<p>however im having trouble coding it...</p>

<p>any help is much appreciated</p>
