Styling loops with CSS
Posted: Thu Nov 17, 2011 2:05 pm
Hello all!
I'm a PHP noob and I have a question regarding mixing PHP with HTML and CSS. I'm sure this is really obvious, but I haven't been able to find out anything on Google. How would I style each line that is output from this while loop separately? For example, the first line that is output reads "John is 24 and lives in London" and I want this text to be red, but the second line reads "Lucy is 34 and lives in Manchester" and I want this text to be blue, and so on through 11 different MySQL rows.
I hope this is clear enough!
Many thanks!
I'm a PHP noob and I have a question regarding mixing PHP with HTML and CSS. I'm sure this is really obvious, but I haven't been able to find out anything on Google. How would I style each line that is output from this while loop separately? For example, the first line that is output reads "John is 24 and lives in London" and I want this text to be red, but the second line reads "Lucy is 34 and lives in Manchester" and I want this text to be blue, and so on through 11 different MySQL rows.
Code: Select all
$query = "SELECT * FROM new_table";
$result = mysql_query($query);
while ($row=mysql_fetch_array($result)) {
echo $row['name'] . " is " . $row['age'] . " and lives in " . $row['location'] . "<br />";Many thanks!