Jump to content

need help on getting data from 2 different tables


pixeltrace

Recommended Posts

guys,

 

i need help,

 

i have a page that should get items from 2 different tables

specialization and applicant

 

in the specialization, its as to display all items on the table for "specialization"

in the applicant, it has to display the total number of counts equivalent to specialization

 

ex.

 

administration (1)

agricultural (1)

 

the administration and agricultural will be taken from the specialization table

 

and the (1) will be taken from the applicant table

 

below is my codes for this page

<table width="558" border="0" cellspacing="2" cellpadding="3">
                      <tr>
                        <td colspan="2" valign="top"><img src="images/spacer.gif" width="10" height="1" /></td>
                      </tr>
                      <tr>
                        <td colspan="2" bgcolor="#999999" class="text2">RESUME MANAGER  </td>
                      </tr>
                      <tr>
                        <td colspan="2" valign="top"><img src="images/spacer.gif" width="10" height="10" /></td>
                      </tr>
                      <tr>
                        <td colspan="2" valign="top" bgcolor="#83C2ED" class="text2">Specialization  </td>
                      </tr>

		<?
$query = mysql_query("SELECT specialization FROM specialization") or die(mysql_error()); 
$row = mysql_fetch_array( $query );
		$specialization = $row["specialization"];
			?>
                      <tr>
                        <td width="4" align="left" valign="top" class="text6"><img src="images/spacer.gif" width="4" height="10" /></td>
                        <td width="536" align="left" valign="top" class="text6">» <? echo "$specialization";?> <a href="resumemngr.php?id=3&specialization=<? echo "$specialization"; ?>" class="link2">[

<?
$query = mysql_query("SELECT specialization, COUNT(*) AS cnt FROM applicant WHERE specialization LIKE '%". $specialization ."%';") or die(mysql_error()); 
$row = mysql_num_rows($query);
?>
			<? echo "$row";?>
					]</a></td>
                      </tr>
		  <?
			}    
			}
			?> 
                  </table>

 

this codes are not working and i dont know how to fix it,

hope you could help me with this.

 

thanks!

A few things.  Are you getting any errors?  If so post them.  Next, maybe try changing the names of your variables, I don't think this is causing the problem, but change the variable names on your second set of queries.  Are you getting any output at all?  If the data in your tables spans more than one row you will need to echo all that out using a while or for loop.  Just my 2 cents.

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.