if(isset($_POST['article_sort']) AND isset($_POST['article_order'])){ $sort = $_POST['article_sort']; $order = $_POST['article_order']; $sql_article_sort = send_sql("UPDATE post_sort SET str='$sort' WHERE name='article_sort'") OR die(mysql_error()); $sql_article_order = send_sql("UPDATE post_sort SET str='$order' WHERE name='article_order'") OR die(mysql_error()); } else { $sql_article_sort = mysql_query("SELECT str FROM post_sort WHERE name='article_sort'") OR die(mysql_error()); $sql_article_sort = mysql_fetch_row($sql_article_sort); $sql_article_order = mysql_query("SELECT str FROM post_sort WHERE name='article_order'") OR die(mysql_error()); $sql_article_order = mysql_fetch_row($sql_article_order);//and later on$tmp=mysql_query("SELECT * FROM articles ORDER BY '$sql_article_sort[1]' '$sql_article_order[1]'");