Jump to content


Photo

Need help with Blog system


  • Please log in to reply
4 replies to this topic

#1 caffeblog

caffeblog
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 30 September 2006 - 03:26 PM

Hello.  I have a blog community system at www.caffeblog.com .  I am trying to insert a Random Blog redirect into it where when a person clicks on the "Random Blog" link it will redirect them to a blog on the system.  It works almost perfect now, however sometimes it redirects the user to a blank page due to previously deleted blogs on the system.

Is there any way to overcome this issue?  ???

Len
www.CaffeBLOG.com

#2 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 30 September 2006 - 03:34 PM

how do you determine the random blog? the best way to do it is to run a select query ordering by random, but only select the active blogs. that way, you can feel confident that the one you link to will be a good link. make sense?

we could help you a little better if we knew how you were creating your links and retreiving your random entry
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#3 caffeblog

caffeblog
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 30 September 2006 - 06:34 PM

how do you determine the random blog? the best way to do it is to run a select query ordering by random, but only select the active blogs. that way, you can feel confident that the one you link to will be a good link. make sense?

we could help you a little better if we knew how you were creating your links and retreiving your random entry


Hello.  The rotation program is looking at a section of the mysql tables to see if an entry is there.  An active entry is a "1", a formerly active is a "0".  The blog program does not totally delete out a formerly active entry due to former username issues.  That is where I am running into the problems.  I need the rotation program to distinquish between an active entry of '1' and ignore the '0'.  I do not have the experience to know what code to put in the rotation program to do this.

Len
www.CaffeBLOG.com

#4 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 30 September 2006 - 06:38 PM

run a query to filter out the inactive ones and randomly choose one of those that is active:
SELECT * FROM blogPosts WHERE active = '1' ORDER BY RAND() LIMIT 1;

You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#5 caffeblog

caffeblog
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 30 September 2006 - 09:20 PM

run a query to filter out the inactive ones and randomly choose one of those that is active:

SELECT * FROM blogPosts WHERE active = '1' ORDER BY RAND() LIMIT 1;


Thanks!  I will give that a try.

Len




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users