May be stupid question, but I'm not sure how to extend this code to order for example by published name, by size, by name and etc, just make more ordering buttons.
This is code:
$query ="SELECT newsvid.id, newsvid.addName, newsvid.vidTitle, newsvid.url, newsvid.vidSD, newsvid.published, videoinformation.vidLD, videoinformation.vidYear, videoinformation.vidCity, videoinformation.vidZanr, videoinformation.vidZanr2, videoinformation.vidZanr3, videoinformation.vidQuality, videoinformation.vidTranslated, videoinformation.vidTime FROM newsvid, videoinformation WHERE newsvid.id = videoinformation.id";
$order = isset($_GET['order']) ? $_GET['order'] : 'ASC';
$goodParam = array("ASC", "DESC");
if (in_array($order, $goodParam)) {
if($order == 'ASC'){
$query .= " ORDER BY newsvid.id ASC";
}else{
$query .= " ORDER BY newsvid.id DESC";
}
}
And this is my buttons:
<a href="view.php?order=ASC">ASC</a>
<a href="view.php?order=DESC">DESC</a>
P.S. I use samples from internet and adopt to my website and now can't extended, not sure how.
Thank you
What exactly I need to change in php code to use this links?
<a href="view.php?order=ASC">ASC</a>
<a href="view.php?order=name">BY Name</a>
<a href="view.php?order=year">By Year</a>
<a href="view.php?order=published">By Publishing</a>
<a href="view.php?order=size">By Size</a>
DO I have to using like this??
if (in_array($order, $goodParam)) {
if($order == 'ASC'){
$query .= " ORDER BY newsvid.id ASC";
}else if{
$query .= " ORDER BY newsvid.vidTitle DESC";
}else if{
$query .= " ORDER BY newsvid.published DESC";
}else{
$query .= " ORDER BY videoinformation.vidZard DESC";
}
}