-4
while ($row1=mysql_fetch_array($sql1); $row2=mysql_fetch_array($sql2))

{
    echo $row1['line'];
    echo $row1['style_no'] ;
    echo $row2['line'];
    echo $row2['style_no'] ;

}
CSᵠ
  • 10,049
  • 9
  • 41
  • 64
  • Can you please make more of an effort to describe your problem properly? – Marty Oct 23 '14 at 05:11
  • 4
    ***Notice:*** There is **no more support** for `mysql_*` functions, they are [**officially deprecated**](https://wiki.php.net/rfc/mysql_deprecation), **no longer maintained** and will be [**removed**](http://php.net/manual/en/function.mysql-connect.php#warning) in the future. You should update your code with [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) to ensure the functionality of your project in the future. – CSᵠ Oct 23 '14 at 05:14

2 Answers2

1

Combine them with and

while ($row1 = mysql_fetch_assoc($sql1) and $row2 = mysql_fetch_assoc($sql2)) {
    ...
}

But it would probably be better to combine the two queries into one with a JOIN.

Barmar
  • 741,623
  • 53
  • 500
  • 612
0

You can do it in this way:

while ($row1=mysql_fetch_array($sql1) && $row2=mysql_fetch_array($sql2)) {
    echo $row1['line'];
    echo $row1['style_no'] ;
    echo $row2['line'];
    echo $row2['style_no'] ;
}
Efog
  • 1,155
  • 1
  • 15
  • 33
  • Hi Efog; thax for the advice.....but according to your way...it run only second Query ($sql2) and Echo only $row2['line'] and $row2['style_no'], even other query ($sql1) have output. – Gayan Chaturanga Oct 23 '14 at 05:55
  • Maybe $row2 have more rows then $row1? Why cannot you combain two queries in SQL? – Efog Oct 23 '14 at 05:57