Much obliged in advance for any help. Here's what I'm trying to do:
I have 2 data tables each with different fields but both using the same values for the primary keys, establishing a one to one relationship between the two. The first table "dealer_list" contains records for every authorized dealer for my company and the second table "dealer_ind" contains more specific information, but only for some, not all, of the dealers in the the "dealer_list" table. I have a page that dynamically displays the general information for all our dealers from the "dealer_list" table and I am attempting to attach a hyperlink to the dealer name for records that also have data in the "dealer_ind" table which will send the user to a new page with more detailed information by passing the primary key value, or simply display the dealer's name if not. Here's the code I'm currently working with, although I've tried a few other things to no avail as well.
Code: Select all
function SqlData($p_value)
{
//$returnvalue = mysql_real_escape_string($p_value);
$returnvalue = $p_value;
return $returnvalue;
}
$result = mysql_query("SELECT * FROM dealer_list WHERE dlr_state=\"".SqlData($_GET["item_abbv"])."\" ORDER BY dlr_city, dlr_name",$db);
<? while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { ?>
<tr class="bodysmall">
<td height="26" align="left">
<? if (in_array($row["dlr_number"],array("SELECT ind_dlrnum FROM dealer_ind"))) { ?>
<a href="dealers_ind_detail.php?item_dlrnum=<? echo($row["dlr_number"]); ?>" target="_blank"><? echo($row["dlr_name"]); ?></a>
<? }
}
else {
echo($row["dlr_name"]);
<? } ?>
<? } ?>
</td>
<td align="left"><? echo($row["dlr_address"]); ?></td>
<td align="left"><? echo($row["dlr_city"]); ?></td>
<td align="left"><? echo($row["dlr_state"]); ?></td>
<td align="left"><? echo($row["dlr_zip"]); ?></td>
<td align="left"><? echo($row["dlr_phone"]); ?></td>
</tr>
<? } ?>