I have a mysql table with a column for subscription types called Topic. The info in the column is an array divided by commas (kids, youth, couples, etc...). I'm trying to explode the array ($SubTypes), then query (select) each result in a different table, and then print both the first exploded array and it's results from the query. Below is my code.

if($Subscription) {
$SubType = $Subscription;
$SubTypes = explode("," , $SubType);
for ($x = 0; $x < count($SubTypes); $x++) {
$SubQuery = mysql_query("SELECT * FROM EmailBodyDB WHERE Topic LIKE '$SubTypes[$x]'");
$SubAnswer = mysql_fetch_assoc($SubQuery);
$Content[$x] = $SubAnswer[Content];
if($SubTypes[$x]) {
echo "<p>",$SubTypes[$x],"<br>",$Content[$x],"</p>";
}
}
}

What I get is the first exploded array ($SubType) and it's $Content, and the other arrays ($SubType) with no $Content.

Any advice?

    the problem is probably the way you handle arrays. Note the use of {} below

    if($Subscription) 
    { 
      $SubType = $Subscription; 
      $SubTypes = explode("," , $SubType); 
      for ($x = 0; $x < count($SubTypes); $x++) 
      { 
        $SubQuery = mysql_query("SELECT * FROM EmailBodyDB WHERE Topic LIKE '{$SubTypes[$x]}'"); 
        $SubAnswer = mysql_fetch_assoc($SubQuery); 
        $Content[$x] = $SubAnswer['Content']; 
        if($SubTypes[$x]) 
        { 
          echo '<p>',$SubTypes[$x],'<br>',$Content[$x],'</p>'; 
          //or could be written as:
          //echo "<p>{$SubTypes[$x]}<br>{$Content[$x]}</p>"; 
        }//if
      }//for
    }//if 
    

      Thanks, but still not working.

        Could this be because of the

        if($SubTypes[$x])

        maybe this should be

        if($Subscription)  
        {
        $SubType = $Subscription;
        $SubTypes = explode("," , $SubType);
        for ($x = 0; $x < count($SubTypes); $x++)
        {
        $SubQuery = mysql_query("SELECT * FROM EmailBodyDB WHERE Topic LIKE '{$SubTypes[$x]}'");
        $SubAnswer = mysql_fetch_assoc($SubQuery);
        $Content[$x] = $SubAnswer['Content'];
        while($SubAnswer = mysql_fetch_assoc($SubQuery); )
        {
        echo '<p>',$SubTypes[$x],'<br>',$SubAnswer['Content'],'</p>';
        }//if }//for }//if
          Write a Reply...