digitalrain Posted May 25, 2006 Share Posted May 25, 2006 Hey folks...Here's my situation:I have a bunch of images sorted by month -- one image for each day of thatmonth. Each image has a corresponding 'teaser' or summary text (no, it's notadult related in any way, shape or form).I need to be able to display the current day's 'teaser' in a designated box onmy homepage along with a "[read more]" link. Both the teaser and the linkwould 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 cansearch 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 withit, 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 = '<ahref="'.tep_href_link('dailydevotions.php').'">'.$innerText.'...<BR>[More]</a>';[/code]Any help is appreciated.Thanks,ChickieGamer Quote Link to comment https://forums.phpfreaks.com/topic/10402-desperately-need-help/ Share on other sites More sharing options...
gerkintrigg Posted May 25, 2006 Share Posted May 25, 2006 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_URLID - This'll be the primary keynow 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. Quote Link to comment https://forums.phpfreaks.com/topic/10402-desperately-need-help/#findComment-38921 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.