include "header.php";
if(isset($_GET['EntryID'])) //If looking at a specific Article
{
$EntryID=$_GET['EntryID'];
$tviewed = "UPDATE CMS_articles SET timesviewed=timesviewed+1
WHERE EntryID = '$EntryID'";
mysql_query($tviewed);
$article="SELECT * FROM CMS_articles where EntryID='$EntryID'";
$article2=mysql_query($article) or die("It died");
if(mysql_num_rows($article2) == 0){
echo "Article Not Found
Sorry, no article found with this detail go to homepage and try again.
";
print "
";
}else{
$atitle = stripslashes(mysql_result($article2,0,'title'));
$abody = stripslashes(mysql_result($article2,0,'body'));
print "";
print "
";
print "$atitle";
print "
";
print "$abody
";
print "";
print "
";
print "
";
}
}
else if(isset($_POST['submit']) || isset($_POST['searchterm']) || isset($_GET['searchterm'])) //if user pressed search
{
$numentries=5;
if(!isset($_GET['start']))
{
$start=0;
}
else
{
$start=$_GET['start'];
}
$searchterm=$_POST['searchterm'];
if(isset($_GET['searchterm'])) $searchterm=$_GET['searchterm'];
$newselect="Select * FROM CMS_articles where title LIKE '%$searchterm%' OR shortdescription LIKE '%$searchterm%' OR body LIKE '%$searchterm%' order by EntryID DESC LIMIT $start, $numentries";
$newsquery=mysql_query($newselect) or die("dies");
if(mysql_num_rows($newsquery) == 0){
echo "No Results
Sorry, your search did not produce any results. Please try another search.
";
}else{
while($news=mysql_fetch_array($newsquery))
{
print "$news[title]
";
print "$news[shortdescription]
";
print "
";
}
}
$order="SELECT * FROM CMS_articles where title LIKE '%$searchterm%' OR shortdescription LIKE '%$searchterm%' OR body LIKE '%$searchterm%'";
$order2=mysql_query($order);
$d=0;
$f=0;
$g=1;
if(!isset($term))
{
$term=$look;
}
print "Page: ";
while($order3=mysql_fetch_array($order2))
{
if($f%$numentries==0)
{
$term=$searchterm;
print "$g ";
$g++;
}
$d=$d+1;
$f++;
}
}
else if(!isset($_POST['submit'])) //looking at root
{
$numentries=5;
if(!isset($_GET['start']))
{
$start=0;
}
else
{
$start=$_GET['start'];
}
$newselect="Select * FROM CMS_articles order by EntryID DESC LIMIT $start,$numentries";
$newsquery=mysql_query($newselect) or die("dies");
while($news=mysql_fetch_array($newsquery))
{
$atitle = stripslashes($news['title']);
$ashortdescription = stripslashes($news['shortdescription']);
print "$atitle
";
print "$ashortdescription
";
print "
";
}
$order="SELECT * from CMS_articles";
$order2=mysql_query($order);
$d=0;
$f=0;
$g=1;
print "Page: ";
while($order3=mysql_fetch_array($order2))
{
if($f%$numentries==0)
{
print "$g ";
$g++;
}
$d=$d+1;
$f++;
}
}
include "footer.php";
?>