<?php
 

 // --------------------------------------------------------------------------
 
 
 // wheatblog app :: index.php
  // purpose :: Echoes out blog posts   
 

 // --------------------------------------------------------------------------

  

 // define the vars + include the header
 



 $page_title = "<a href=http://rebecca.hallqvist.se/schooner/wheatblog/index.php title=tillbaks>schooner</a>";
 
 $prefix = "../";
 
 $template = 3;
  include("$prefix" . "whp_header.inc");
?>

<?php
 



 // wheatblog code: start

   

 // read in the connection settings
   


 require("wheatblog_settings.inc");

   



 // connect to the RDBMS
   


 $db = mysql_connect("$site","$user","$pass") 
       

 or die("<h2>Could not connect to database server</h2><p>Check passwords and sockets</p>");

 
  
 

 // select the database
   


 mysql_select_db("$database",$db) 
       

 or die("<h2>Could not select database $database</h2><p>Check database name</p>");

   



 // select recent posts in the database
   


 $result = mysql_query("select * 
from $database_table 
where showpref = '1'order by year DESC, month DESC, date DESC, id DESC 
       

 limit $front_page_max",$db) 
       

 or die("<h2>Could not select posts</h2>");



 // output the current entries        

  

 echo("<!-- generated by wheatblog: start -->\n\n");

   

 while($row = mysql_fetch_array($result)) {
        $the_id = $row["id"];
       
 $the_day = $row["day"];
       

 $the_month = $row["month"];
       

 $the_date = $row["date"];
       

 $the_year = $row["year"];
       

 $the_category = $row["category"];

       



 // testing
       

 // echo("<br />THE CATEGORY: $the_category<br />");
            
           


 // parse out the category id into its string value
           


 $result2 = mysql_query("select *   
               

 from $database_table_categories   
               

 where id = '$the_category'",$db)
               

 or die("<h2>Could not select category</h2>"); 

           

 while($row2 = mysql_fetch_array($result2)) {
       $the_category_name = $row2["category"];
            }

       


 // testing
       

 // echo("<br />THE CATEGORY: $the_category<br />");
       

 // echo("<br />THE CATEGORY NAME: $the_category_name<br />");

   
    

 $the_showpref = $row["showpref"];
       

 $the_title = $row["title"];
       

 $the_body = $row["body"];
       

 $number_of_comments = $row["number_of_comments"];

       



 // posts
       

 echo("\n\n<div class=\"indent\">\n");
       

 echo("<br /><br /><span class=\"desc_header\">$the_day" . ", " . "$the_date" . "/" . "$the_month" . " " . "$the_year" . " :: " . "$the_title" . "</span><br />\n");
       

 echo("$the_body" . "<br />\n");
       
 echo("[<a href=\"view_by_category.php?the_category=$the_category\"" . ">" . "$the_category_name" . "</a>] ");
       

 echo("[" . "<a href=\"view_by_permalink.php?the_id=$the_id\"" . ">" . "kommentarer ($number_of_comments)" . "</a>]\n");
       

 echo("</div>\n\n");
    }

    echo("<!-- generated by wheatblog: stop -->\n\n");
   

 echo("<br><br><br><br>\n<div class='description'>gjord med <a href='http://wheatblog.sourceforge.net' target=_blank title='blogware for the rest of us'>wheatblog</a>
 </div>");
 

 // wheatblog code: stop
?>

<?php
        


 // include the footer

 
 include("$prefix" . "whp_footer.inc");
?>