Jump to content

Latest Blog Entries


phpnewbie123

Recommended Posts

I would like to add the latest blog entries on member's profile page and have tried ways and means to do it myself. Being a newbie... I just could not do it somehow.

Please help me... I would like to add the last 5 blogs to the page...

 

 

 

<!-- blogs -->

<?php

    if($show==1)

    {

?>

<table bordercolor="000000" cellspacing="3" cellpadding="0" width="435" align="center" bgcolor="ffffff" border="0">

<tr>

<td width="435" style="word-wrap:break-word">

<span class="btext">

<?=$name?>'s Latest Blog Entry [<a href=subscribe_blog.php?member_id=<?=$HTTP_GET_VARS["member_id]?>">Subscribe to members Blog</a>]<br><br>

</td>

</tr>

 

<?php

    $num_blogs=$profile->get_num_blogs($HTTP_GET_VARS["member_id"]);

    if($num_blogs==0)

    {

?>

<td valign="top" align="left">

<span class="lightbluetext8">

No blogs entered by user yet.

</span>

</td>

</tr>

<?php

    }

    else

    {

        $blog_info=$profile->get_latest_blog($HTTP_GET_VARS["member_id"]);

?>

<tr valign="top">

<td valign="top" align="left" width="435">

<span class="lightbluetext8">

<?=$blog_info["subject"]?> 

</span>

(<a href="view_blog.php?id=<?=$blog_info["id"]?>">view more</a>)

<br><br>

</td>

</tr>

 

<tr>

<td valign="top" align="left" bgcolor="ffffff" height="25">

[<a href=view_member_blog.php?member_id=<?=$HTTP_GET_VARS["member_id]?>">View All Blog Entries</a>]</td>

</tr>

<?php

    }

?>

</table><br>

<!-- blogs -->

Link to comment
https://forums.phpfreaks.com/topic/74403-latest-blog-entries/
Share on other sites

I can show you an example of a generic method, but looking at your code, it would seem your using some pre-built blog system so it might not be of much help.

 

<?php

  // connect to db.

  $sql = "SELECT title,blog,stamp FROM blogs ORDER by stamp DESC LIMIT 5;";
  if ($result = mysql_query($sql)) {
    if (mysql_num_rows($result)) {
      while ($row = mysql_fetch_assoc($result)) {
        echo "<p>{$row['title']} {$row['stamp']}</p>";
        echo "<p>{$row['blog']}</p><hr />";
      }
    }
  }

?>

 

If you want more specifics you will need to be more specific. Maybe try asking your question in a forum based around whatever blog software your using.

Link to comment
https://forums.phpfreaks.com/topic/74403-latest-blog-entries/#findComment-375938
Share on other sites

I can show you an example of a generic method, but looking at your code, it would seem your using some pre-built blog system so it might not be of much help.

 

<?php

  // connect to db.

  $sql = "SELECT title,blog,stamp FROM blogs ORDER by stamp DESC LIMIT 5;";
  if ($result = mysql_query($sql)) {
    if (mysql_num_rows($result)) {
      while ($row = mysql_fetch_assoc($result)) {
        echo "<p>{$row['title']} {$row['stamp']}</p>";
        echo "<p>{$row['blog']}</p><hr />";
      }
    }
  }

?>

 

If you want more specifics you will need to be more specific. Maybe try asking your question in a forum based around whatever blog software your using.

 

THanks... I'll try this first.

I had asked the question on the software forum but none could help me. Not even the script programmer....

thanks anyway...

Link to comment
https://forums.phpfreaks.com/topic/74403-latest-blog-entries/#findComment-376194
Share on other sites

Can you show us the contents of view_blog.php ?

 

blog.pdf is the contents of view_blog.php....

mypage.pdf is where i would like the latest update to appear....

 

 

view_blog php file

 

<?php

    }

    else

    {

 

    if($id==Null || !is_numeric($id))

    {

?>

<tr>

<td valign="top" bgcolor="#FFFFFF" class='err_class'>

Err # Invalid blog selected, cannot be displayed.

<br>

</td>

</tr>

<tr>

<td valign="top" bgcolor="#FFFFFF" class='err_class'>

<br>

</td>

</tr>

 

<?php

    }

    else

    {

    $blog_info=$blog->get_blog($HTTP_GET_VARS["id"]);

    $creator=$blog->get_creator($HTTP_GET_VARS["id"]);

   

    if($blog_info["privacy"]=="1")

    {

        // check for preffered list

       

                $sql="select count(*) as a from member_friends where member_id = $blog_info[member_id] and friend_id = $_SESSION[member_id] and approve = 1";

                $num_res=mysql_query($sql);

                $num_set=mysql_fetch_array($num_res);

 

        if($num_set["a"] == 0 && $creator!=$_SESSION["member_id"])

        {

?>

<tr>

<td valign="top" bgcolor="#FFFFFF" class='err_class'>

Err #  You are not allowed to view this blog..

<br>

</td>

</tr>

<tr>

<td valign="top" bgcolor="#FFFFFF" class='err_class'>

<br>

</td>

</tr>

 

<?php

          die();

        }

    }

    $res=$blog->update_counter($HTTP_GET_VARS["id"]);

?>

 

<!-- Blog Entry -->

 

<table width="100%">

<tbody>

<tr>

<td vAlign=top width="20%">

<?php

    include("includes/people.class.php");

    $people=new people;

    include("includes/profile.class.php");

    $profile=new profile;

 

    $name=$people->get_name($blog_info["member_id"]);

    $num_images=$people->get_num_images($blog_info["member_id"]);

    if($num_images==0)

    {

        $image="<img alt='' src='images/no_pic.gif' width=90 border=0>";

    }

    else

    {

        $image_url=$people->get_image($blog_info["member_id"]);

        $image="<img alt='' src='$image_url' width=90 border=0>";

    }

    $people_info=$people->get_info($blog_info["member_id"]);

    $profile_info=$people->get_profile($blog_info["member_id"]);

    $profile_back=$profile->get_back($blog_info["member_id"]);

    $basic_info=$profile->get_basic($blog_info["member_id"]);

?>

 

<!-- user_profile -->

<table class=profile>

<tbody>

<TR>

<TD align=middle>

<p>

<a href="view_profile.php?member_id=<?=$blog_info["member_id"]?>"><B><?=$name?></B></A><BR>

<a href="view_profile.php?member_id=<?=$blog_info["member_id"]?>">

<?php

    print $image;

?>

</a><br></p>

<div class=DataPoint=OnlineNow;UserID=4885511; id=UserDataNode0 style="WIDTH: 80px; HEIGHT: 20px">

</DIV>

<p></p>

<p class='txt_label'><b>Last Updated:</b><br><?=$blog_info["last_updated"]?></p>

</td></tr>

<TR>

<TD align=middle>

<?php

    if($blog_info["member_id"]==$_SESSION["member_id"])

    {

?>

<a href="post_blog.php">Post New Blog</A><BR>

<a href="email_friend.php?blog_id=<?=$HTTP_GET_VARS["id"]?>">Email to a Friend</A>

<?php

    }

?>

</td>

</tr></tbody></table>

<br>

<table class='txt_label'>

<tbody>

<tr>

<td class='txt_label'><B>Gender</B>: <?=$people_info["gender"]?>

<?php

    if($profile_back["marital_status"]!=Null)

    {

?>

<br>

<b>Status</b>:

<?php

    }

 

if($profile_back["marital_status"]=="O")

{

?>

Swinger

<?php

}

?>

<?php

if($profile_back["marital_status"]=="R")

{

?>

In a relationship

<?php

}

?>

 

<?php

if($profile_back["marital_status"]=="S")

{

?>

Single

<?php

}

?>

 

<?php

if($profile_back["marital_status"]=="D")

{

?>

Divorced

<?php

}

?>

 

<?php

if($profile_back["marital_status"]=="M")

{

?>

Married

<?php

}

?>

 

<?php

        $num_days=4;

        $num_days=$num_days*2;

        $num_days=$num_days+5;

        $num_days=$num_days*50;

 

        $m=date("m");

        $d=date("d");

 

        if($m <= $basic_info["birth_month"])

        {

            $num_days=$num_days+1755;

        }

        else

        {

            $num_days=$num_days+1754;

        }

        $num_days=$num_days-$basic_info["birth_year"];

 

        //print "Num Days = $num_days";

        //$years = substr($num_days,1,3);

        $time_now=strtotime("now");

        $time_birth=strtotime($basic_info["dob"]);

        //print $time_birth;

        //print "<br>";

        //print $time_now;

 

        $diff = $time_now - $time_birth;

 

        $mins = $diff/60;

        $hours = $mins/60;

        $days = $hours/24;

        $days = round($days,0);

        //print "Days = $days";

        $years = $days/365;

        $years = round($years,0);

        if($years > 36)

        {

            $years = $years + 0;

        }

        //print "Days = $days";

 

 

        //$days=datediff($basic_info["dob"], GetTodayDate(0));

        //$years=$days/365;

        //$years=substr($years,0,2);

 

        //print $basic_info["dob"];

        //print GetTodayDate(0);

        //$days=abs(new_datediff("-",$basic_info["dob"],GetTodayDate(0)));

        //$years=$days/365;

        //$years = round($years,0);

        //print $years;

        /*

        $sql="SELECT DATEDIFF('2006-11-18','$basic_info[dob] 00:00:00') as aa";

        $date_res=mysql_query($sql);

        $date_set=mysql_fetch_array($date_res);

        $days=$date_set["aa"];

        $years = $days/365;

        $years = round($years,0);

        */

?>

<BR><B>Age</B>: <?=$years?> Years

<BR><B>City</B>:<?=$people_info["city"]?>

<BR><B>State</B>: <?=$basic_info["current_state"]?><BR>

<?php

if($people_info["country"]!=Null)

{

if(is_numeric($people_info["country"]))

{

  $sql="select * from states where state_id = $people_info[country]";

  $country_res=mysql_query($sql);

  $country_set=mysql_fetch_array($country_res);

}

}

?>

<B>Country</B>: <?=$country_set["state_name"]?><BR>

</TD></TR></TBODY></TABLE><BR>

<TABLE class=profile>

<TBODY>

</TBODY></TABLE><BR></TD>

<TD width=5>

<IMG height=1 alt="" src="images/spacer.gif" width=5 border=0></TD>

 

<td vAlign=top width="100%">

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>

<TBODY>

<TR class=spacer>

<TD></TD></TR></TBODY></TABLE>

<table width='100%' cellSpacing='0' cellPadding='10'>

<TBODY>

<TR>

<td width="100%">

<p class="blogTimeStamp"><b>Posted On:</b> <?=$blog_info["posted_month"]?>/<?=$blog_info["posted_day"]?>/<?=$blog_info["posted_year"]?></p>

<table class=blog cellSpacing=0 cellPadding=0 width="100%" border=0>

<TBODY>

<TR>

<TD width=30><IMG height=1 alt="" src="images/spacer.gif" width=#blogIndent# border=0>

</TD>

<TD class='txt_label'>

<P class='txt_label'><?=$blog_info["subject"]?>

<br>Current mood:

<?php

    $mood_image=$blog->get_mood_image($blog_info["mood"]);

    $mood=$blog->get_mood_name($blog_info["mood"]);

    if($mood_image!=Null)

    {

?>

<img src="<?=$mood_image?>" width='20' height='20' align=absMiddle> <?=$mood?>

<?php

    }

?>

</p>

<P class='txt_label'>

<?=stripslashes($blog_info["body"])?>

</P>

 

<b>

<?php

  $num_comments=$blog->get_num_comments($blog_info["id"]);

  $num_kudos=$blog->get_num_kudos($blog_info["id"]);

?>

<?=$num_comments?> Comments

</b>

-

<b>

<?=$num_kudos?> Kudos

</b> -

<a href="add_blog_comment.php?id=<?=$HTTP_GET_VARS["id"]?>">

<b>Add Comment</b></a> -

<?php

    $creator=$blog->get_creator($blog_info["id"]);

    if($creator==$_SESSION["member_id"])

    {

        $show=1;

    }

    else

    {

      if($_SESSION["member_id"]!=Null)

      {

      $sql="select count(*) as a from blog_moderators where member_id = $_SESSION[member_id]";

      $res=mysql_query($sql);

      $data_set=mysql_fetch_array($res);

 

      if($data_set["a"]==1)

      {

          $show=1;

      }

      else

      {

          $show=0;

      }

      }

      else

      {

          $show=0;

      }

    }

   

if($show==1)

{

 

?>

<a href="edit_blog.php?id=<?=$blog_info["id"]?>">

<b>Edit</b>

</a>

- <a onclick="if( confirm('Are you sure you want to remove this blog?') ){return true;}else{ return false; }" href="delete_blog.php?id=<?=$blog_info["id"]?>">

<b>Remove</b>

</a>

<?php

}

?>

</p></td></tr></tbody></table></td>

</tr></tbody></table>

<br>

 

<!-- blog_ comments -->

<?php

    $comments_res=$blog->get_blog_comments($blog_info["id"]);

    while($comment_set=mysql_fetch_array($comments_res))

    {

        $commentor_name=$people->get_name($comment_set["member_id"]);

       

    $num_images=$people->get_num_images($comment_set["member_id"]);

    if($num_images==0)

    {

        $gender=$people->check_gender($comment_set["member_id"]);

        if($gender=="Male")

        {

          $image="<img alt='' src='images/male.gif' width='90' border=0>";

        }

        else

        {

          $image="<img alt='' src='images/female.gif' width='90' border=0>";

        }

    }

    else

    {

        $image_url=$people->get_image($comment_set["member_id"]);

        $pic_name=str_replace('user_images/', '', $image_url);

        $image = "<img src='image_gd/image_logincomplete.php?$pic_name' border='0'>";

    }

?>

<table cellspacing="0" cellpadding="0" width="100%">

<tr>

<td><img src="images/clear.gif" height="1" width="0"></td>

<td class="blogCommentsProfile">

<a href="view_profile.php?member_id=<?=$comment_set["member_id"]?>" class="profileLinks"><?=$commentor_name?></a><br>

<a href="view_profile.php?member_id=<?=$comment_set["member_id"]?>">

<?=$image?></a><br>

<DIV style="width:80px;height:20px;" ID="UserDataNode1" CLASS="DataPoint=OnlineNow;UserID=4885511;"></div>

</td>

<td class="blogComments" width="100%">

<table cellpadding="5" cellspacing="0" border="0" width="100%">

<tr>

<td class="txt_label" valign='top'>

<p class="txt_label"><?=stripslashes($comment_set["body"])?></p>

<p class="txt_label">Posted by <a href="view_profile.php?member_id<?=$comment_set["member_id"]?>"><b>

<?=$commentor_name?></b></a> on <?=$comment_set["posted_on"]?>

<?php

    if($comment_set["comment_id"]!=0)

    {

?>

<p class="blogCommentsContent">Posted For Comment

<?php

    $comment=$blog->get_comment($comment_set["comment_id"]);

?>

<br>

<b><?=stripslashes($comment["body"])?></b></a><br> which was posted on <?=$comment["posted_on"]?>

<?php

    }

?>

<br>

<?php

    if($show==1)

    {

?>

[<a href=remove_comment.php?blog_id=<?=$blog_info["id]?>&comment_id=<?=$comment_set["id"]?>" onmouseover="window.status='Remove this blog comment';return true;" onmouseout="window.status='';return true;" onclick="return confirm('Are you sure you want to remove this blog comment?')"><b>Remove</b></a>]

<?php

    }

?>

[<a href=add_blog_comment1.php?blog_id=<?=$blog_info["id]?>&comment_id=<?=$comment_set["id"]?>" onmouseover="window.status='Reply to this comment';return true;" onmouseout="window.status='';return true;"><b>Reply to this</b></a>]

</p></td>

</tr>

</table>

</td>

</tr>

<tr class="commentSpacer">

<td colspan="3"></td>

</tr>

</table>

<?php

    }

}

}

?>

<!-- blog_comments -->

</table>

<!-- middle_content -->

 

 

<!-- Middle Text -->

<?php

include("includes/bottom.php");

?>

 

 

thanks!

 

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/74403-latest-blog-entries/#findComment-378482
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.