Wrox Programmer Forums
|
BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9
This is the forum to discuss the Wrox book PHP and MySQL: Create-Modify-Reuse by Timothy Boronczyk, Martin E. Psinas; ISBN: 9780470192429
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 8th, 2012, 10:55 AM
Authorized User
 
Join Date: May 2011
Posts: 12
Thanks: 0
Thanked 2 Times in 2 Posts
Default Adapting and extending scripts

I have successfully installed the blog scripts and now I'm trying to do extend my programming abilities. As suggested by the author I am trying to build up and create something specific for my needs. I would like to be able to print out comments with each blog entry together with the username and avatar: something similar to the Forum which I am using as a guide to do the same here. However, although my script prints out all the correct information for each post_id, it does not separate between the blog entries; it dumps the same information into each blog. Does anyone have any suggestions how to identify the correct blog; it would be much appreciated.

Code:
// retrieve avatar for this post
$id = (int)$_GET['post_id'];

$query = <<<ENDSQL
SELECT
    USERNAME, POST_COMMENT,
              UNIX_TIMESTAMP(COMMENT_DATE) AS COMMENT_DATE
FROM
   ALBION_BLOG_COMMENT B JOIN ALBION_USER U
        ON B.USER_ID = U.USER_ID
ORDER BY COMMENT_DATE ASC

ENDSQL;

    $query = sprintf($query, DB_TBL_PREFIX, $id);

    $result = mysql_query($query, $GLOBALS['DB']);

if (mysql_num_rows($result))

{
    while($row = mysql_fetch_assoc($result))
    {

        echo htmlspecialchars($row['USERNAME']) . '<br/>';
        echo date('m/d/Y', $row['COMMENT_DATE']) . '<br/>';
        echo htmlspecialchars($row['POST_COMMENT']) . '<br/>';
        
        if (file_exists('avatars/' . $row['USERNAME'] . '.jpg'))
        {
            echo '<img src="avatars/' . $row['USERNAME'] . '.jpg" alt="avatar"/><br/>';
        }
        else
        {
            echo '<img src="img/default_avatar.jpg" alt="avatar"/><br/>';
        }
    }
}





Similar Threads
Thread Thread Starter Forum Replies Last Post
Extending ASPNETDB malie22001 BOOK: Beginning ASP.NET 4 : in C# and VB 3 December 17th, 2011 05:21 AM
Adapting Ch. 20 code, to create a 'SELECT' DataSet ? liamfitz BOOK: Visual Basic 2008 Programmer's Reference ISBN: 978-0-470-18262-8 1 July 7th, 2009 10:56 AM
Adapting Guestbook for DNN 4.x? [email protected] BOOK: Professional DotNetNuke Module Programming ISBN: 978-0-470-17116-5 6 May 12th, 2009 06:41 AM
Adapting HTML in Linux anukagni Beginning PHP 5 May 30th, 2006 07:09 PM
Adapting class.DataManager for MySQL mercury7 PHP Databases 0 January 16th, 2006 02:37 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.