My database:
--------------------------------------------
| id | col1 | col12 | col3 | col4 |
--------------------------------------------
| id | item1 | 40000 | $400 | 1 |
| id | item1 | 60000 | $300 | 0 |
| id | item1 | 80000 | $200 | 0 |
| id | item1 | 10000 | $800 | 1 |
--------------------------------------------
My query:
$sqlCommand = "SELECT * FROM table ORDER BY id";
$query = mysql_query($sqlCommand) or die (mysql_error());
$var = '';
while ($row = mysql_fetch_array($query)) {
$id = $row['id'];
$var1 = $row['col1'];
$var2 = $row['col2'];
$var3 = $row['col3'];
$var3 = $row['col4'];
$var .= "<div id='div1'><img src='$var1'/></div>
<div id='div2'>$var2</div>
<div id='div3'>$var3</div>
<div id='div4'>$var4</div>";
}
How I want it to output the data is the items that have a “1” in col3 should be bold and possibly a different colour and the other text remains whatever the page font/text is set out as.
As below
---------------------------------------------------
| id | col1 | col12 | col3 |
---------------------------------------------------
| id | item1 | 40000 | $400 |
| id | item1 | 60000 | $300 |
| id | item1 | 80000 | $200 |
| id | item1 | 10000 | $800 |
---------------------------------------------------
Is this possible within a while loop? If not then how else could I do it?
1 Answer