Page 1 of 1

How do I add a style to this output

Posted: Fri Nov 18, 2005 9:00 am
by mhouldridge
Hi,

I would like to add a class to the date output from the following php;

Code: Select all

echo '<span class="standard">';

              echo "<a href='viewasset.php?varl=".$myrow['title']."' class=\"blue8\">".$myrow['title']."</a>";
			  
			  echo "<br> ";
			   
			  echo $myrow['text1'];
			   
			  echo "<br><class=\"blue8\">Postdate: ";
			   
			  echo $myrow['dtime'];

			  echo "<br> ";
			echo "<br> ";
I have already assigned a class in the first echo statement however I need different styles for each row.

Posted: Fri Nov 18, 2005 9:45 am
by Burrito
I don't see any rows defined. do you mean you want to alternate the the row styles or every third or what?

if you just want to alternate you can do something like this:

Code: Select all

$on = TRUE;
while($row = mysql_fetch_assoc($result))
{
    echo "<tr class=\"".$on ? "class1" : "class2"."\">"; // etc
    $on = !$on;
}
if you want to do more than alternate, take a look at the modulus operator.

Posted: Fri Nov 18, 2005 10:57 am
by jayshields
I think you misinterpreted (spelling?) him.

He refers to "rows" as echo statement, echo <br>, echo statement, etc, I don't think he wants a table.

This should really be in the client side forum.

To assign style classes just put this <span class="classname">styled text</span>, then to style some other text differently, <span class="otherclassname">differently styled text</span>.

In your code you don't close your span tags, and you also try <class="whatever">, which can't be done.