cool thanks hey StarLion do you have any books that could help me out as much as I like to post here I want to really learn this stuff my self. Like a php for dummies or some thing I got the every easy simple stuff or should I say the straight forward stuff (depending on your opinion of straight forward) But some of this stuff just goes over my head.
Obligatory response: Check out the sitepoint books in the Products section!
Uhm… as far as the very, very basics… the PHP manual is where i do 90% of my referencing. PHP: A simple tutorial - Manual
When I started PHP I had a book; the book was very comprehensive. Comprehensive though isnt what I wanted. I had specific questions, specific problems that I wanted to solve.
<?php
include 'blogpost.php';
// Change this info so that it works with your system.
$connection = mysql_connect() or die ("<p class='error'>Sorry, we were unable to connect to the database server.</p>");
$database = "basic";
mysql_select_db($database, $connection) or die ("<p class='error'>Sorry, we were unable to connect to the database.</p>");
function GetBlogPosts($inId=null, $inTagId =null)
{
if (!empty($inId))
{
$query = mysql_query("SELECT * FROM blog_posts WHERE id = " . $inId . " ORDER BY id DESC");
}
else if (!empty($inTagId))
{
$query = mysql_query("SELECT blog_posts.* FROM blog_post_tags LEFT JOIN (blog_posts) ON (blog_post_tags.postID = blog_posts.id) WHERE blog_post_tags.tagID =" . $tagID . " ORDER BY blog_posts.id DESC");
}
else
{
$query = mysql_query("SELECT * FROM blog_posts ORDER BY id DESC");
}
$postArray = array();
while ($row = mysql_fetch_assoc($query))
{
$myPost = new BlogPost($row["id"], $row['title'], $row['img_post'], $row['post'], $row['postfull'], $row["author_id"], $row['datePosted']);
array_push($postArray, $myPost);
}
return $postArray;
}
?>
This is the blogpost.php
<?php
class BlogPost
{
public $id;
public $title;
public $img_post;
public $post;
public $author;
public $tags;
public $datePosted;
function __construct($inId=null, $inTitle=null, $inPost=null, $inPostFull=null, $inAuthorId=null, $inDatePosted=null)
{
if (!empty($inId))
{
$this->id = $inId;
}
if (!empty($inTitle))
{
$this->title = $inTitle;
}
if (!empty($inPost))
{
$this->post = $inPost;
}
if (!empty($inDatePosted))
{
$splitDate = explode("-", $inDatePosted);
$this->datePosted = (count($splitDate) >= 2) ? ($splitDate[1] . "/" . $splitDate[2] . "/" . $splitDate[0]) : $inDatePosted;
}
if (!empty($inAuthorId))
{
$query = mysql_query("SELECT first_name, last_name FROM people WHERE id = " . $inAuthorId);
$row = mysql_fetch_assoc($query);
$this->author = $row["first_name"] . " " . $row["last_name"];
}
$postTags = "No Tags";
if (!empty($inId))
{
$query = mysql_query("SELECT tags.* FROM blog_post_tags LEFT JOIN (tags) ON (blog_post_tags.tag_id = tags.id) WHERE blog_post_tags.blog_post_id = " . $inId);
$tagArray = array();
$tagIDArray = array();
while($row = mysql_fetch_assoc($query))
{
array_push($tagArray, $row["name"]);
array_push($tagIDArray, $row["id"]);
}
if (sizeof($tagArray) > 0)
{
foreach ($tagArray as $tag)
{
if ($postTags == "No Tags")
{
$postTags = $tag;
}
else
{
$postTags = $postTags . ", " . $tag;
}
}
}
}
$this->tags = $postTags;
}
}
?>
I’m modifying some code that I got. I used it before ans it worked fine now I’m trying to change the style and I added the image section that’s it nothing fancy and it’s not working.