Froggaard Posted October 9, 2013 Share Posted October 9, 2013 Hello. I have this code, but how can I do so the latest news is shown and they other are closed? I can't figure it out by my self, there are ask you guys $res = mysql_query("select * from news order by added desc") or die(mysql_error());if (mysql_num_rows($res) > 0) { while ($news = mysql_fetch_assoc($res)) {$ret = ($CURUSER['class'] >= 10 ? " <a href='admin_news.php?action=edit&id={$news['id']}'><img src='{$SITEINFO['picdir']}edit.png' alt='Ret' title='Ret' /></a>":"");$slet = ($CURUSER['class'] >= 10 ? " <a href='admin_news.php?action=slet&id={$news['id']}'><img src='{$SITEINFO['picdir']}delete.png' alt='Slet' title='Slet' /></a>":"");$added = $news['added'];$newstext = $news['body'];if ($CURUSER) {$new = ($CURUSER['news_readed'] == 'no' ? "<img src='{$SITEINFO['picdir']}new.gif' alt='' border='0' />":"");}if ($news['youtube'] != "")$newstext .= "<br/><iframe title='YouTube video player' class='youtube-player' type='text/html' width='640' height='390' src='https://www.youtube.com/embed/$news[youtube]' frameborder='0' allowFullScreen></iframe>";$ud .= "<div style='background:;height:20px;text-align:center;'><span style='font-weight:bold;font-size:15pt;'>{$news['title']}</span>{$new}</div>n";$ud .= "<span style='font-weight:bold;text-decoration:underline;'><a href="javascript:klappe('{$news['id']}')">{$added}</a></span>{$ret}{$slet}n";$ud .= "<div style='margin-top:10px;padding:5px;display:none;' id='k{$news['id']}'>".text($newstext)."</div><hr />n";if ($CURUSER) {mysql_query("update users set news_readed = 'yes' where id = '{$CURUSER['id']}' limit 1") or die(mysql_error());}}} Link to comment Share on other sites More sharing options...
justsomeguy Posted October 9, 2013 Share Posted October 9, 2013 If the klappe function does what you want to happen for these, then after you print each div you can print some Javascript code to run that function on the div. You can use a counter or another variable to tell if you're on the first item or not. Link to comment Share on other sites More sharing options...
Froggaard Posted October 10, 2013 Author Share Posted October 10, 2013 Got it to work Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now