I have an article submission script, but on the listing pages the articles come out in order of date posted not a-z (how i want it)
how will I do this?
this is my code for the page
when ever i do this now, I get an error that says,
Warning: sort() expects parameter 1 to be array, string given in /home/user/public_html/directory/article.php on line 86
<?php
$configFile="config.php";
require $configFile;
//Connect to database
$db = mysql_connect("$host", "$username", "$password");
mysql_select_db("$databasename", $db);
if($id)
{
$getArticle=mysql_query("SELECT * FROM $tablename WHERE id=$id", $db);
//This is errorCount
$eC;
//aC is articleContent
if($aC=mysql_fetch_array($getArticle))
{
$eC=false;
$newCount=$aC["novisitors"]+1;
$countVisit=mysql_query("UPDATE $tablename SET novisitors='$newCount' WHERE id='$id'",$db);
}
else
{
$eC=true;
}
$title=$aC['title'];
}
else
{
$title="Articles";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title><?php echo $title;?></title>
</head>
<body>
<h2 align="left">
<?php
if(!$eC){echo $title;} else { echo "Error";}
echo "</h2>";
if($id)
{
if(!$eC)
{
echo "<p align=\"left\">By ";
printf($aC["author"]);
echo "</p>";
}
echo "</p>
<p align=\"left\">";
if(!$eC)
{
printf($aC["full"]);
echo "</p>";
echo "<p align=\"left\"><i>This article is by ";
printf($aC["author"]);
echo "</i></p>";
}
else
{
echo "Sorry there has been a problem. Please try again";
}
echo "<br><br><a href=\"$PHP_SELF?action=main\">More articles</a>";
}
//Do main menu
if(!$id||$action=="main")
{
$result = mysql_query("SELECT * FROM `$tablename` WHERE complete!=0 ORDER BY `id` DESC",$db);
if ($therow = mysql_fetch_array($result))
{
do
{
echo "<b>";
sort($title);
printf($therow["title"]);
echo "</b><br><i>";
printf($therow["date"]);
echo "</i><br>";
printf($therow["summary"]);
echo "<br><a href=\"$PHP_SELF?id=";
printf($therow["id"]);
echo "\">Read</a>...";
echo "<br><br>";
}
while ($therow = mysql_fetch_array($result));
}
else
{
echo "Sorry there are no completed articles at the moment";
}
}
?>
</body>
</html>