Jump to content


Photo

Desperately need help...


  • Please log in to reply
1 reply to this topic

#1 digitalrain

digitalrain
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 25 May 2006 - 01:41 AM

Hey folks...

Here's my situation:

I have a bunch of images sorted by month -- one image for each day of that
month. Each image has a corresponding 'teaser' or summary text (no, it's not
adult related in any way, shape or form).

I need to be able to display the current day's 'teaser' in a designated box on
my homepage along with a "[read more]" link. Both the teaser and the link
would link to a page that displays the current day's image.

On that page I need a link to the daily image archives, which the user can
search by date using 2 select boxes (one for month and one for day) which will,
upon clicking 'submit', display the corresponding image.

I was given this snippet of code to get started but am unsure of what to do with
it, what tables and fields are needed in the database, etc...:

$SQL = "SELECT teaser FROM devotions WHERE date =
'2002-".date('m')."-".date('d')."' LIMIT 1";
    $result = mysql_query($SQL) or die(mysql_error());
    $num_rows = mysql_num_rows($result);
    if($num_rows == 0)
    {
        $SQL = "SELECT teaser FROM devotions WHERE date =
'2003-".date('m')."-".date('d')."' LIMIT 1";
        $result = mysql_query($SQL) or die(mysql_error());
    }
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
    {
        $innerText = $row["teaser"];
    }
    $innerText = '<a
href="'.tep_href_link('dailydevotions.php').'">'.$innerText.'...<BR>[Mor
e]</a>';

Any help is appreciated.

Thanks,

ChickieGamer

#2 gerkintrigg

gerkintrigg
  • Members
  • PipPipPip
  • Magician
  • 828 posts
  • LocationBristol, UK
  • Age:37

Posted 25 May 2006 - 02:09 PM

Okay... here goes!! *gulp*
First you need to have N fields in the database:

Text (which you can chop down into teaser text or duplicate this field into both "text" and "teaser")
Img_URL
ID - This'll be the primary key

now the image will be stored in the Img_URL field.

what you'll need to do is use the ID field as a link identifier to tell the browser which image and text field to open.

So once you define the code to get the database information and you begin cycling through the entries using a while loop, the PHP link code will be something like this:

<a href="http://www.whatever.com/wherever/read.php?<?php echo $row['ID'];?>">Click me</a>

If none of that makes sense yet, I VERY STONGLY recommend looking at a few tutorials. I know... I hated doing them too,l but you learn a LOT!!

So there you go... the rest will fall into place soon, just get your head around that first.
Neil Trigger - http://www.ghostlypublishing.co.uk - Ghostly Publishing - Children's Fantasy Books




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users