shetrick 0 Newbie Poster

Hi,

I need some help. I have data in a table (cust) and one of the columns has multiple values in it (cat_id). I need to use those values to select data (cat_name) from a second table (cat) and display this with the data from the first table where (cat_id) are the same. The data is writen into (cust) in an area that is serialize then unserialize. Thanks in advance.

<table width="100%" border="0" align="center" cellpadding="4" cellspacing="4">
  <tr> 
    <td bordercolor="#000000" bgcolor="#F4F4F4"> 
      <?php
$i=0;
while ($i < $num) {
$f1=mysql_result($result,$i,"fname");
$f2=mysql_result($result,$i,"lname");
$f3=mysql_result($result,$i,"address");
$f4=mysql_result($result,$i,"city");
$f14=mysql_result($result,$i,"state");
$f5=mysql_result($result,$i,"zip");
$f6=mysql_result($result,$i,"phone");
$f7=mysql_result($result,$i,"fax");
$f8=mysql_result($result,$i,"email");
$f10=mysql_result($result,$i,"website");
$f11=mysql_result($result,$i,"comments");
$f12=mysql_result($result,$i,"cat_id");
$f12=unserialize($f12);
$f12 = implode(",",$f12);
$f13=mysql_result($result,$i,"cust_id");
$f15=mysql_result($result,$i,"area_id");

?>
<?php 
$query2=" SELECT * FROM category WHERE cat_id IN ('$f12')";
$result2=mysql_query($query2) or die(mysql_error());;
$row = mysql_fetch_array($result2);
mysql_close();

$f16=mysql_result($result2,$i2,"cat_name");

?>

<?php 
$query3=" SELECT * FROM area WHERE area_id=$f15";
$result3=mysql_query($query3) or die(mysql_error());;
$num3=mysql_numrows($result3);
mysql_close();
$f19=mysql_result($result3,$i3,"area_name");
?>

      <div align="left"><font size="4"><strong><u><font size="3"> </font></u></strong></font><a href="directoryedit.php?cust_id=<?php echo $f13; ?>"><font size="4"><strong><u><font size="3"> 
        </font></u></strong></font>Click to Edit </a><font size="3"><strong></strong></font><font size="3" face="Times New Roman, Times, serif"><strong> 
        <br>
        </strong></font></div></td>
    <td colspan="4" bordercolor="#000000" bgcolor="#F4F4F4"><div align="left"> 
      </div>
      <div align="center"><a href="directoryadd.php">Click to Add</a></div></td>
    <td valign="top" bordercolor="#000000" bgcolor="#F4F4F4"><a href="directorydelete.php?id=<?php echo $f13; ?>">Click 
      to Delete</a> </td>
  </tr>
  <tr> 
    <td bordercolor="#000000" bgcolor="#F4F4F4"> <div align="left"><strong><font size="3" face="Times New Roman, Times, serif"><?php echo $f1; ?></font></strong></div></td>
    <td colspan="3" bordercolor="#000000" bgcolor="#F4F4F4"><div align="left"><strong><font size="2" face="Times New Roman, Times, serif"><?php echo $f2; ?></font></strong></div></td>
    <td bordercolor="#000000" bgcolor="#F4F4F4"><div align="left">Phone - <font size="2" face="Times New Roman, Times, serif"><?php echo $f6; ?></font></div></td>
    <td bordercolor="#000000" bgcolor="#F4F4F4"><div align="left">Fax - <font size="2" face="Times New Roman, Times, serif"><?php echo $f7; ?></font></div></td>
  </tr>
  <tr> 
    <td colspan="4" bordercolor="#000000" bgcolor="#F4F4F4"><div align="left"><font size="2" face="Times New Roman, Times, serif"><?php echo $f3; ?></font></div>
      <div align="left"></div></td>
    <td bordercolor="#000000" bgcolor="#F4F4F4"><div align="left">Email - <font size="2" face="Times New Roman, Times, serif"><a href="mailto:<?php echo $f8; ?>"><?php echo $f8; ?></a></font></div></td>
    <td bordercolor="#000000" bgcolor="#F4F4F4"><div align="left"><font size="2" face="Times New Roman, Times, serif">Website 
        - <a href="http://<?php echo $f10; ?>" target="_blank"><?php echo $f10; ?></a></font></div></td>
  </tr>
  <tr> 
    <td colspan="2" bordercolor="#000000" bgcolor="#F4F4F4"><div align="left"><font size="2" face="Times New Roman, Times, serif"><?php echo $f4; ?></font></div></td>
    <td bordercolor="#000000" bgcolor="#F4F4F4"><div align="left"><font size="2" face="Times New Roman, Times, serif"><?php echo $f14; ?></font></div></td>
    <td bordercolor="#000000" bgcolor="#F4F4F4"><div align="left"><font size="2" face="Times New Roman, Times, serif"><?php echo $f5; ?></font></div></td>
    <td bordercolor="#000000" bgcolor="#F4F4F4"><font size="2" face="Times New Roman, Times, serif">Category 
      - <?php echo $f12;?> <?php echo $f16;?></font></td>
    <td bordercolor="#000000" bgcolor="#F4F4F4"><font size="2" face="Times New Roman, Times, serif">Area 
      - <?php echo $f19 ; ?></font></td>
  </tr>
  <tr> 
    <td colspan="4" bordercolor="#000000" bgcolor="#F4F4F4"><font size="2" face="Times New Roman, Times, serif">Comments<br>
      <br>
      <?php echo $f11; ?></font></td>
    <td bordercolor="#000000" bgcolor="#F4F4F4"><font size="2" face="Times New Roman, Times, serif"><?php echo $results2; ?></font></td>
    <td bordercolor="#000000" bgcolor="#F4F4F4">&nbsp;</td>
  </tr>
  <tr> 
    <td colspan="6" bordercolor="#000000" bgcolor="#333333">&nbsp;</td>
  </tr>
  <tr> 
    <td bordercolor="#000000" bgcolor="#F4F4F4"><font size="2" face="Times New Roman, Times, serif"> 
      <?php
$i++;
}
?>
      </font></td>
    <td colspan="3" bordercolor="#000000" bgcolor="#F4F4F4">&nbsp;</td>
    <td bordercolor="#000000" bgcolor="#F4F4F4">&nbsp;</td>
    <td bordercolor="#000000" bgcolor="#F4F4F4">&nbsp;</td>
  </tr>
</table>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.