Jump to content

Please help (2 mysql query one in one)


FilipKrstic

Recommended Posts

Hello everybody,

I`m coding something, and after hours and hours of coding, I`m goona in trapping.  :facewall:

 

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

"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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.