spiritwalker Posted March 18, 2012 Share Posted March 18, 2012 Hi, I am new here and fairly new to php, i am currently trying to manipulate data from a mysql data table but i am struggling a little with some syntax. Basically i am tabulating data on a web page with php from mysql but i want to apply different styles from css if certain fields are within certain values. I am struggling with gettting an if statement to work within a while loop which populates the table. I would be grateful if someone could point me in the right direction. Heres a snippet of my code but its not liking the syntax it seems to be within the if statement as when its not there it works fine. Thanks in advance while($row=mysql_fetch_array($result)){ echo "</td><td>"; echo $row['testid']; echo "</td><td>"; echo $row['sampleid']; echo "</td><td>"; echo $row['testcode']; echo "</td><td>"; echo $row['testdesc']; echo "</td><td>"; echo $row['receptiondate']; echo "</td><td>"; echo $row['enddate']; echo "</td>"; if ( $row['expiry'] < 24 ) { echo "<td class="data">$row['expiry']</td>"; } else { echo echo "<td>"$row['expiry']; } echo "</td></tr>";}echo "</table>"; Link to comment Share on other sites More sharing options...
dsonesuk Posted March 18, 2012 Share Posted March 18, 2012 You have a conflict with quotes for echo and quotes for html, plus you join php to html string with "." + two echo in else if ( $row['expiry'] < 24 ){echo '<td class="data">'.$row['expiry'].'</td>';}else{echo '<td>'.$row['expiry'];} Link to comment Share on other sites More sharing options...
spiritwalker Posted March 18, 2012 Author Share Posted March 18, 2012 wow thanks ill give that a whirl tomorrow night its had me stumped for a few days lol i was googling around but found not a lot in relations to ifs in while loops. Thanks again Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.