Jump to content

[SOLVED] table displaying alernet codes... php not working :S


runnerjp

Recommended Posts

<?php
session_start();
require_once '../settings.php';
$getthreads="Select * from forumtutorial_posts  ORDER BY lastrepliedto  DESC LIMIT 10";


$getthreads2=mysql_query($getthreads) or die("Could not get threads");

while($getthreads3=mysql_fetch_array($getthreads2))

{

  $getthreads3[title]=strip_tags($getthreads3[title]);

  $getthreads3[author]=strip_tags($getthreads3[author]);?>

   <br>
  <b>
<?php

$currentcolor = "#00468C";

echo '<table width="500 border="0" >';

while($row = mysql_fetch_array($getthreads2, MYSQL_ASSOC))
{ 
    $currentcolor = ($currentcolor=='#00468C' ? '#000000' : '#00468C');
    echo '<tr bgcolor="'. $currentcolor .'">
                <td><? echo $getthreads3[title]?> </td>
            </tr>';
}

echo '</table>';

?> 
</b> <? } ?>

 

from this all i get is 3 different colour lines :S

 

can be seen here  http://www.runningprofiles.com/members/test.php

Link to comment
Share on other sites

Modified your code abit, not sure what you was doing with your first while loop but doesn't seem it was required

<?php
session_start();
require_once '../settings.php';

$sql    = "Select * from forumtutorial_posts  ORDER BY lastrepliedto  DESC LIMIT 10";
$result = mysql_query($sql) or die("Could not get threads");

echo '<table width="500 border="0" >';

$i = 0;
while($row = mysql_fetch_assoc($resul))
{
    $color = (($i%2 == 0) ? '#000000' : '#00468C');

    echo "\n".'  <tr bgcolor="'. $color .'">
  <td>'.$row['title'].'</td><td>'.$row['author'].'</td>
  </tr>';

  $i++;
}

echo '
</table>';

?>

Link to comment
Share on other sites

thnaks... what does (($i%2 == 0) ?  mean?

The code above checks to see if the remainder is equal to 0. the modulus operater (%) returns the remainder.

 

also.. in "Select * from forumtutorial_posts  ORDER BY lastrepliedto  DESC LIMIT 10";

 

how would i do it so it only gets the results where lastrepliedto doesnot = 0 ?

Set a condition in your select statement:

$sql    = "Select * from forumtutorial_posts WHERE lastrepliedto != 0 ORDER BY lastrepliedto DESC LIMIT 10";

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.