Jump to content

Desperately need help...


digitalrain

Recommended Posts

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...:

[code]
$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>';
[/code]

Any help is appreciated.

Thanks,

ChickieGamer
Link to comment
Share on other sites

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:

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

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.
Link to comment
Share on other sites

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.