Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a Mysql table which is use in php, first I use while loop to fetched the rows that as below

$q1 = "SELECT * FROM same_table WHERE `t_type`=1 AND `status`=0 AND `accept`='0'";

while($row1 = $q1->fetch_assoc()){

    ...table to output records

    echo '<tr>
          <td>$row1['col1']</td>
          <td>$row1['col2']</td>
          </tr>';
}

this will come out necessary records successfully.

secondly, there is another row with different purpose located under each of the above query row if the condition is true, with same table (within while loop),

while($row1 = $q1->fetch_assoc()){
    echo '<tr>
          <td>$row1['col1']</td>
          <td>$row1['col2']</td>
          </tr>';

    $q2 = "SELECT * FROM same_table WHERE `t_type`=1 AND `status`=0 AND `bonus_accept`='0'";

    $row2 = $q2->fetch_assoc();

    if(($row2['col3'] == true){
        echo '<tr>
              <td>$row2['col1']</td>
              <td>$row2['col2']</td>
              </tr>';
    }

}

so far the $q2 rows is show but always repeat the first record's data only even there is several row for $q1. if the data for $row2['col1'] is 100, the rest all show 100.

Please kindly help.

share|improve this question
    
you have not' execute the query. –  SKRocks Feb 25 at 7:24
    
@Satish Sharma, yes it does in my real code, I just want to simplify the codes above –  conmen Feb 25 at 7:28
    
what's your actual need, your question is not understandable completely. –  Rizwan Shamsher Kaim Khani Feb 25 at 8:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.