Note that there are some explanatory texts on larger screens.

plurals
  1. POchanging td's color with if statement
    text
    copied!<p>I'm trying to use <code>if</code>-statement to change <code>&lt;td&gt;</code>-s color. </p> <p>Basically, I have a simple query to retrieve information from the database. Additionaly, I have a column there which keeps the information like if the task is accomplished or not. When I retrieve the information I get all of them, but I need the accomplished tasks to be green, and others without any color.</p> <p>I've searhed for the answer, but I couldn't find anything that satisfies me. </p> <p>For example:</p> <hr> <pre><code>$qry = mysql_query("select * from table"); $recs = array(); while($row = mysql_fetch_array($qry)) $recs[]=$row; mysql_free_result($qry); </code></pre> <hr> <p>I've tried to add while statement to the code above, but I was confused and it didnt work :(</p> <p>I'm printing the results using heredoc: How to give them color here?</p> <hr> <pre><code>&lt;?php $last_id=0; foreach($recs as $rec) { $html=&lt;&lt;&lt;HTML &lt;tr&gt; &lt;td&gt;&lt;b&gt;Номер&lt;/b&gt;&lt;/td&gt; &lt;td&gt;$rec[0]&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Номер документа&lt;/b&gt;&lt;/td&gt; &lt;td&gt;$rec[1]&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Дата регистрации&lt;/b&gt;&lt;/td&gt; &lt;td&gt;$rec[8]&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;От кого&lt;/b&gt;&lt;/td&gt; &lt;td&gt;$rec[2]&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;По&lt;/b&gt;&lt;/td&gt; &lt;td&gt;$rec[4]&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Краткое содержание&lt;/b&gt;&lt;/td&gt; &lt;td&gt;$rec[3]&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Исполнитель&lt;/b&gt;&lt;/td&gt; &lt;td&gt;$rec[5]&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Срок исполнения&lt;/b&gt;&lt;/td&gt; &lt;td&gt;$rec[6]&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Срок исполнения продлен до&lt;/b&gt;&lt;/td&gt; &lt;td&gt;&lt;b&gt;$rec[10]&lt;/b&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Прислан&lt;/b&gt;&lt;/td&gt; &lt;td&gt;$rec[9]&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Примечание&lt;/b&gt;&lt;/td&gt; &lt;td&gt;$rec[7]&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td bgcolor="#838B83"&gt;&amp;nbsp;&lt;/td&gt; &lt;td bgcolor="#838B83"&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; HTML; print $html; if($rec[0]&gt;$last_id) $last_id=$rec[0]; }; $new_id=$last_id+1; ?&gt; </code></pre> <hr>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload