FilipKrstic Posted July 29, 2009 Share Posted July 29, 2009 Hello everybody, I`m coding something, and after hours and hours of coding, I`m goona in trapping. Here is code... <?php $query1 = mysql_query("select * from v2_ispitnirok order by id desc"); while($data1 = mysql_fetch_array($query1)) { echo "<table width='86%' border='1' align='center' cellspacing='0' bordercolor='#E9E5C0' style='border-collapse: collapse' colspan='2'> <tbody> <tr class='head'> <td bgcolor='#E9E5C0' style='text-align: left;'><strong>$data1[naslov]</strong></td> </tr> <tr class='head'><td width='170%' style='text-align: left;'>"; $ispitnirok = "$data1[id]"; $query2 = mysql_query("select * from v2_rezispita where $ispitnirok = `ispitnirok` and order by id desc"); Line 521 if($data2 = mysql_fetch_array($query2)) { echo" $data2[naslov], $data2[datum], $data2[rezultat]"; } echo"</td></tr> </tbody> </table><br />"; } ?> and line 521 is problem... Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/w0500004/public_html/razvoj/vtsa/index.php on line 521 What I try to do. I tried to list data from table v2_ispitnirok, use their id, and compare him in second query with "select * from v2_rezispita where $ispitnirok = `ispitnirok` and order by id desc", and list data from second table. but after that I have a problem with if($data2 = mysql_fetch_array($query2)) ??? Anyone to help? Link to comment https://forums.phpfreaks.com/topic/168027-please-help-2-mysql-query-one-in-one/ Share on other sites More sharing options...
gevans Posted July 29, 2009 Share Posted July 29, 2009 change if to a while loop while($data2 = mysql_fetch_array($query2)) { Link to comment https://forums.phpfreaks.com/topic/168027-please-help-2-mysql-query-one-in-one/#findComment-886231 Share on other sites More sharing options...
FilipKrstic Posted July 29, 2009 Author Share Posted July 29, 2009 Same... Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/w0500004/public_html/razvoj/vtsa/index.php on line 521 Link to comment https://forums.phpfreaks.com/topic/168027-please-help-2-mysql-query-one-in-one/#findComment-886239 Share on other sites More sharing options...
gevans Posted July 29, 2009 Share Posted July 29, 2009 "select * from v2_rezispita where $ispitnirok = `ispitnirok` and order by id desc" should be "select * from v2_rezispita where $ispitnirok = `ispitnirok` order by id desc" caps make this a lot easier "SELECT * FOME `v2_rezispita` WHERE $ispitnirok = `ispitnirok` ORDER BY `id` desc" If $ispitnirok isn't an integer it needs to be wrapped in single quotes Link to comment https://forums.phpfreaks.com/topic/168027-please-help-2-mysql-query-one-in-one/#findComment-886260 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.