Jump to content

Recommended Posts

Currently I have a list of blog entries on my website. The problem is that the bloggers are writing multiple entries and knocking others off the list. I want to make it so that no one can have have more than one entry on the list.

 

Below is the cut of code generating the list. After the php code I have an example of the output.

 

<?php

$db_host = "********";

$db_user = "********";

$db_pwd = "***********";

$db_name = "******************";

$connection = mysql_connect($db_host, $db_user, $db_pwd) or die("Blogs are Updating");

mysql_select_db($db_name) or die("Blogs are Updating");

?>

<?php

 

$query = "SELECT bhost_entries.e_id,bhost_entries.title,bhost_entries.contents,bhost_users.username,bhost_users.display_name, bhost_weblogs.weblog FROM bhost_entries,bhost_users, bhost_weblogs WHERE bhost_entries.author_u_id = bhost_users.u_id AND bhost_weblogs.u_id = bhost_users.u_id AND privacy='3' AND bhost_entries.draft = 0 ORDER BY bhost_entries.e_id DESC LIMIT 25";

$result = mysql_query($query);

 

 

function summarise($paragraph, $limit)

 

{

  $textfield = strtok($paragraph, " ");

  while($textfield)

  {

  $text .= " $textfield";

  $words++;

  if(($words >= $limit))

  // PUT IN GAP ABOVE FOR COMPLETE SENTANCE POSTING

  //  && ((substr($textfield, -1) == "!")||(substr($textfield, -1) == ".")||(substr($textfield, -1) == "")||(substr($textfield, -1) == ",")||(substr($textfield, -1) == "?")||(substr($textfield, -1) == ";"))

  break;

  $textfield = strtok(" ");

  }

  return ltrim($text); 

}

 

 

 

echo mysql_error();

while(list($id,$title,$contents,$username,$user, $blogname) = mysql_fetch_array($result))

{

if(empty($title))

$title = "Untitled Entry";

 

 

echo "

  <tr>

<td><div class=\"arrow\"></div></td>

<td><div class=\"blog_title\"><a href=\"/blog/?w=$blogname&e_id=$id/\" title=\"$title\">$blogname</a></div></td>

  </tr>

  <tr>

<td colspan=\"2\"><div class=\"blog_text\"><a href=\"/blog/?w=$blogname&e_id=$id/\" title=\"$title\">$title</a></div></td>

  </tr>

";

}

?>

 

The output reads as follows:

 

lifeontheoutside

Pink, Pink and Yes more Pink!!

 

dougleier

CWD monitoring for 2007

 

redsneaker

Photo Teachers are EVIL

 

dougleier

answer questions for deer season

 

dougleier

CRP and the farm bill

 

dougleier

deer season Q & A

 

themichael

Why can't you put a pumpkin in a garbage disposal?

 

dougleier

hunting at 14

 

Notice how this dougleier guy has 5 entries on the list? I only want him to have 1 entry so that other people can have a chance to be featured on the list too.

 

Thanks in advance for your help!

-tomdumont

Link to comment
https://forums.phpfreaks.com/topic/76250-cant-figure-out-how-to-go-about-it/
Share on other sites

I think I am missing the point, do you want only ever a maximum of 1, or the fact that someone else must have blogged again before he can? Way I would do it is through a combination of an autoincremental "recID" field in SQL so can find last blogs and compare with the 1 going in, or otherwise if only 1 entry allow why not "select count(*) where"

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.