Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $query_articles = mysql_query("SELECT * FROM articles ORDER BY article_date DESC LIMIT 30") or die(mysql_error());
- $row_articles = mysql_fetch_assoc($query_articles);
- // Show article #1
- // Then loop through articles 2-7
- // Then show article #8
- // Then loop through articles 9-30
- $query_articles = mysql_query("SELECT * FROM articles ORDER BY article_date DESC LIMIT 32") or die(mysql_error());
- $row_articles = mysql_fetch_assoc($query_articles);
- $shown_articles = array(1, 8);
- $article_index = 1;
- foreach ($row_articles as $article) {
- do {
- if (in_array($article_index, $shown_articles)) {
- echo '<p>'.$article_index.' ';
- echo $row_articles['title'];
- echo '</p>';
- } else {
- echo '<p>'.$article_index.' ';
- echo $row_articles['title'];
- echo '</p>';
- }
- $article_index++;
- } while($row_articles = mysql_fetch_assoc($query_articles));
- }
- $query_articles = mysql_query("SELECT * FROM articles ORDER BY article_date DESC LIMIT 32") or die(mysql_error());
- $shown_articles = array(1, 8);
- $article_range = range(9, 30);
- $article_index = 1;
- while($row_articles = mysql_fetch_assoc($query_articles)) {
- if (in_array($article_index, $shown_articles)) {
- echo '<p>'.$article_index.' ';
- echo $row_articles['title'];
- echo '</p>';
- } elseif (in_array($article_index, $article_range)) {
- echo '<p>'.$article_index.' ';
- echo $row_articles['title'];
- echo ' - 9-30</p>';
- } else {
- echo '<p>'.$article_index.' ';
- echo $row_articles['title'];
- echo ' - 2-7</p>';
- }
- $article_index++;
- }
- $rows = new ArrayIterator($row_articles);
- $articles = new NoRewindIterator($rows);
- foreach ($articles as $i => $article)
- {
- switch ($i)
- {
- case 1:
- article_display($article);
- article_list(new LimitIterator($articles, 0, 6));
- break;
- case 8:
- article_display($article);
- article_list(new LimitIterator($articles, 0, 21));
- break;
- default:
- throw new Excpetion(sprintf("Unexpected i: %d", $i));
- }
- }
- $query_articles = mysql_query("SELECT * FROM articles ORDER BY article_date DESC LIMIT 30") or die(mysql_error());
- $row_articles = mysql_fetch_assoc($query_articles);
- $i=0;
- foreach($row_articles as $article) {
- if($i % 8 == 0) {
- // do stuff for row 0, 8 ..
- }
- else {
- // do stuff for other rows
- }
- $i++;
- }
- $shown_articles = array(1, 8);
- $article_index = 1;
- foreach ($row_article as $article) {
- if (in_array($article_index, $shown_articles)) {
- // Show article
- } else {
- // Do something else
- }
- $article_index++;
- }
- $query_articles = mysql_query("SELECT * FROM articles ORDER BY article_date DESC LIMIT 32") or die(mysql_error());
- $shown_articles = array(1, 8);
- $article_index = 1;
- while ($row_articles = mysql_fetch_assoc($query_articles)) {
- if (in_array($article_index, $shown_articles)) {
- echo '<p>'.$article_index.' ';
- echo $row_articles['title'];
- echo '<br>Stuff for articles in $shown_articles';
- echo '</p>';
- } else {
- echo '<p>'.$article_index.' ';
- echo $row_articles['title'];
- echo '<br>Stuff for articles NOT in $shown_articles';
- echo '</p>';
- }
- $article_index++;
- }
Add Comment
Please, Sign In to add comment