So I am doing a site that has php pull a list of uploaded photos and displays on my page. Then I added a comment box so that the comments specific to that picture can be made. That all works fine. Now I need those comments to show under the comment submit hyperlinked to the forum section where there can be answers made to the comments. I have the basic outline done and most of it works. Here’s where i’m lost… I have a while loop and now within that I need another while loop and it simply won’t work no matter what I’m doing. PLEASE help me on this. I would appreciate it very much. Here is the part of code I’m stuck on:
[php]$result = mysql_query( “SELECT photo_id,photo_caption,photo_filename FROM gallery_photos WHERE photo_category=’”.addslashes($cid)."’" );
$nr = mysql_num_rows( $result );
while($row = mysql_fetch_array( $result ))
{
$result_array[] = "<a href='http://184.173.230.159/~pixipics/members.php?cid=$cid&pid=\"$row[0]\"'><img src='".$images_dir."/tb_".$row[2]."' border='4' alt='".$row[1]."' /></a><br /><p>Comments:</p>
<div class='toggle'>
<form id='form1' name='form1' method='post' action='add_topic.php'>
<table width='100%' border='0' cellpadding='3' cellspacing='1'>
<tr>
<td><strong>Add New Comment:</strong></td>
</tr>
<tr>
<td><textarea name='detail' cols='25' rows='3' id='detail'></textarea></td>
</tr>
<tr>
<td><input type='hidden' id='question_name' name='question_name' value='".$row[2]."'/></td>
</tr>
<tr>
<td><input type='hidden' id='question_filename' name='question_filename' value='".$info['name']."'/></td>
</tr>
<tr>
<td><input type='submit' name='Submit' value='Submit' /> <input type='reset' name='Submit2' value='Reset' /></td>
</tr>
</form>
</table>
<table width='300px' border='0' cellpadding='3' cellspacing='1'>
<tr>
<td><strong>Select a Comment:</strong></td>
</tr>
".$forum."
</table>
</div>";
$sql="SELECT * FROM forum_question WHERE question_filename =\".$row[2].\" ORDER BY id DESC";
$result2=mysql_query($sql);
$forum = "
while ($rows=mysql_fetch_array($result2)){
echo '<tr>
<td><a href=\"view_topic.php?id=\".$rows[id].\"\">\".$rows[detail].\"</a><BR></td>
</tr>';
}";
}[/php]
Now I already know I probably have several issues here but everything is working except for getting $forum to work within the table. I’m open to feedback also so all help would be great. If you need more code I can put the whole page on here but it’s very big so that’s why i didn’t.
Thanks!!