Note that there are some explanatory texts on larger screens.

plurals
  1. POFetching next row of mysql result to compare an index with present row which if being same -> loop output
    text
    copied!<p>So I am generating a report dynamically by fetching values by mysqli_query. This is the current output - > <a href="http://i.imgur.com/87XWAxQ.png?1" rel="nofollow">http://i.imgur.com/87XWAxQ.png?1</a> What I want is that while we are echoing the tasks for the same project the project column display the project title just once and spans through number of tasks under that project, that is TIME MS should appear just once </p> <p>edit - Table Structure - </p> <p>log(<strong>log_id</strong>,proj_id,task_id,user_id,hours,date)</p> <p>projects(<strong>proj_id</strong>,title,desc)</p> <p>tasks(<strong>task_id</strong>,title,desc,user_id,proj_id)</p> <pre><code>$q="SELECT proj_id, task_id,SUM(hours),date FROM log WHERE user_id =$row[0] AND date &gt;= '$s' AND date&lt;= '$e' GROUP BY proj_id, task_id"; $res=mysqli_query($con,$q) or die(mysqli_error($con)); while($row=mysqli_fetch_row($res)) /*while rows exist select each row to extract and display project name task name and sometime calc. Problem - I wanna display just one cell of project name till the tasks under that project are displayed. I know this is achieved by rowspan but using that here is skewing up my table */ { $q="SELECT `title` FROM `projects` WHERE proj_id=$row[0]"; $res=mysqli_query($con,$q) or die(mysqli_error($con)); $ptitle=mysqli_fetch_row($res); $q= "SELECT title FROM tasks WHERE task_id =$row[1]"; $res=mysqli_query($con,$q) or die(mysqli_error($con)); $row=mysqli_fetch_row($res); $time=round(($row[2]/$total[0])*100); echo ' &lt;td&gt;' .$ptitle[0]. //using rowspan here is skewing up the table as // the loop executes seperately for each task '&lt;/td&gt; &lt;td&gt;' .$row2[0]. '&lt;/td&gt; &lt;td&gt;' .$time. '&lt;/td&gt; &lt;/tr&gt;'; } </code></pre> <p>I know there is faulty logic somewhere, but im just not able to figure it out. I need to somehow check if we are still displaying tasks for the same project and count the no. of tasks and set<br> <code>&lt;td rowspan='.$count.'&gt;Project Title&lt;/td&gt;</code> </p>
 

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