Hi!
I have iframe with multiple images retrieved from DB. Each img have "comment" button underneath it. I need this button to redirect to the comment page where user can leave comment . Redirection function works. But at the same time I need this button to send img ID to the comment page.
Iframe is on the main page here's the code:

  <div class="transbox">
<iframe src="index.php" id = "largeimgframe" frameborder="3" width="923" height="490"></iframe>
</div>

Here's the code for index.php: (include function and thumbfunction just resize each image)

<body>
 <div class="thumb"><ul>
<?php
## includes files  
include 'function.php';
include 'thumbfunction.php';
$query = ("SELECT * FROM images WHERE Status = 'public' ORDER BY id DESC ");
$images = simple_func($query);
if(!empty($images))
{
    foreach($images as $image)
    {
         ?>
        <li><img src="uploads/<?=$image['thumb']?>.large.jpg"/>
        <div class="groove3"><input type="button" type="submit" value="Comment" onClick= "self.parent.location.href='com.php';"/>
        </div>
         </p></a></li>
        <?php    
    }
}
else
    {
     ?>
     <div class="message">There are no images to show</div>
   <?php
   }
?>
</ul>
</div>
</body>

**And here's the code for show.php (retrieves images with 'Public' status from DB) **

<?php
## filename show.php
include'file_constants.php';

$con = mysql_connect($host, $user, $pass) or die("Can not connect to database: ".mysql_error());
mysql_select_db($db_name) or die("Can not select the database: ".mysql_error());

if(isset($_GET['id']) || !empty($_GET['id']))
{
$id = $_GET['id'];
$query = mysql_query("SELECT * FROM images WHERE id=' ".$id." ' ");
$row = mysql_fetch_array($query);
$content = $row['image'];
header('Content-type: image/jpg');
echo $content;


mysql_close($con);
}
else
{
 echo "please select image";
 }
 ?>
<input type="button" type="submit" value="Comment" />

I've tried to use <form> but because it is in iframe it didn't work for me. May be I did something wrong(I'm a noob to PHP). Therefore any help would be great!!
Thanks!

Nevermind! Solved!

<?php $imgid = $image['id']; ?>

<li><img src="uploads/<?=$image['thumb']?>.large.jpg"/>
<div class="groove3">
<form action="com.php"  target="_blank" method="post"/>
<input type="hidden" name="imageid" value="<?=$imgid?>" />
<input type="submit" value="Confirm" />
</form>
</div>
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.