theboxjellyfish Posted February 25, 2010 Share Posted February 25, 2010 I have this design idea for a news box.I am trying to think of how to achieve this. I'm still a PHP newbie but essentially I want the picture and summary bit to change when you hover over the recent news items at the bottom and stay there if the person clicks one of the tabs at the bottom. I can't quite think of how to do this. Would the include function work well or am I thinking to much into this by trying to use PHP? What advice can you give me to get to my goal? Thanks for your time. Link to comment Share on other sites More sharing options...
jeffman Posted February 25, 2010 Share Posted February 25, 2010 MOST of this thing is going to be about HTML and JavaScript or very clever CSS. Adding in the data for your News popups will probably be the PHP part. The correct technique depends on how your news is stored on your server.If each news item is stored as plain text in a unique file, the include could work, but it's just as easy to read the file the normal way. Since you'll probably be looping through a whole bunch of files, that might look like this (but not exactly) in your PHP document: $str = "";$len = count($filearray);for ($i = 0; $i < $len; ++$i) { $item = $i + 1; $content = file_get_contents($filearray[$i]); $str .= <<<ENDNEWS<div id="news$item" class="popup"> <h3>News $item</h3> <p>$content</p></div>ENDNEWS;}echo $str; But if you can, it would be more efficient to store your news data in a database. The consequent loop would look a little like the one I just showed you, but also different. since you'd be embedding SQL statements in it instead of file calls. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.