Jump to content

[SOLVED] Displaying content within while loop ?


unsider

Recommended Posts

I need the <?=$row_blog['title'];?> posted in <?=$row_blog['category']?> by <?=$row_blog['name']; content to be alternated in the greycell, and whitecell divs, but for some reason I just can't logically write a piece of code that will accomplish this.

 

<grey>content</grey>

<white>content</white>

 

Sorry about this, I'm just having trouble doing it.

 

<div id="module-latest-threads">
<div class="module-header clear"></div>
<div class="module-left-content clear">
<?php

// SQL query
$query="Select *,COUNT(*) FROM article INNER JOIN categories 
	ON categoryID=catid WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) 
	GROUP BY title DESC LIMIT 3 ";
$blog = mysql_query($query) or die(mysql_error());
$num_blog = mysql_num_rows($blog);
if($num_blog > 0){
while($row_blog = mysql_fetch_assoc($blog)){


$row_blog['title']; posted in $row_blog['category'] by $row_blog['name'];

?>

		<table width="198">		
				<tbody><tr><td class="whitecell">
					<div class="interviews"><a href="">test</a></div> 
			</td></tr>
			<tr><td class="graycell">
					<div class="interviews"><a href="">test</a></div> 
			</td></tr>
			<tr><td class="whitecell">
					<div class="interviews"><a href="">test</a></div> 
			</td></tr>
			<tr><td class="graycell">
					<div class="interviews"><a href="">test</a></div> 
			</td></tr>
			<tr><td class="whitecell">
					<div class="interviews"><a href="">test</a></div> 
			</td></tr>
			<tr><td class="graycell">
					<div class="interviews"><a href="">test</a></div> 
			</td></tr>
			<tr><td class="whitecell">
					<div class="interviews"><a href="">test</a></div> 
			</td></tr>
			<tr><td class="graycell">
					<div class="interviews"><a href="">test</a></div> 
			</td></tr>
			<tr><td class="whitecell">
					<div class="interviews"><a href="">test</a></div> 
			</td></tr>
		</tbody></table>
<?php
}
	} else { 
	echo "No topics to list";		
	} 
?>

		 </div>
		</div>
		<div class="module-separator">
		</div>

Link to comment
Share on other sites

Here, Try this.

 

<div id="module-latest-threads">
  <div class="module-header clear"></div>
  <div class="module-left-content clear">
  <?php
  $query="Select *,COUNT(*) FROM article INNER JOIN categories ON categoryID=catid WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) GROUP BY title DESC LIMIT 3 ";
  $blog = mysql_query($query) or die(mysql_error());
  $num_blog = mysql_num_rows($blog);
  if($num_blog > 0){
    echo "<table width=\"198\"><tbody>";
    $i = 0;
    while($row_blog = mysql_fetch_assoc($blog)){
      $i++;
      if($i % 2) {
        $b = "whitecell";
      } else {
        $b = "graycell";
      }
      echo "<tr><td class=\"".$b."\"><div class=\"interviews\"><a href=\"\">test</a></div></td></tr>";
    }
    echo "</tbody></table>";
  } else { 
    echo "No topics to list";		
  } 
  ?>
  </div>
</div>
<div class="module-separator"></div>

 

Shimmy

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.