php会话数据通过图片ID [关闭]

I want to pass my data to another page with clicking an image and that images id. and ill fetch the data

<body>
<?php include_once("top_temp.php"); ?>

<link rel="stylesheet" href="style/mid_style.css">
<div id="pageMiddle">

<div id="06" class="inner">
<img src="style/ankara.png" alt="ankara" width="64" height="64" title="Ankara">
</div>  
<div id="34" class="inner">
<img src="style/istanbul.png" alt="ankara" width="64" height="64" title="İstanbul">
</div>

You could use GET variables to do this.

Your image link: <a href="page.php?id=1"><img src="image.jpg" alt="my image" /></a>

Then, in page.php, you could check the ID and do whatever you need to do:

$ID = isset($_GET['id']) ? intval($_GET['id']) : null;

if (empty($ID))
{
 // Error handling
}

// Use $ID to fetch whatever data you need

You can use JavaScript and create a submit button from your image

<form id="form-id" action="target.php">
    <img src="file.jpg" onclick="document.getElementById('form-id').submit();" />
    <input type="hidden" name="data" value="42" />
</form>

or you can use direct link

<a href="target.php?data=42><img src="file.jpg" /></a>

You can embed a Form around the image and using a javascript can perform the Form posting. Your image id will be at the Hidden parameters. Here is an example:

<form id="Id" name="Form" method="post">
    <input type="hidden" name="imgid" value="10">
    <a href="#" onclick="document.getElementById('Id').submit();" title="Click to Submit">
        <img src="..."/>
    </a>
</form>

Another option, in jQuery:

HTML

<div id="06" class="inner">
    <img src="style/ankara.png" alt="ankara" width="64" height="64" title="Ankara">
</div>

jQuery

$('.inner img').on('click', function() {
    var id = $(this).parent('div').attr('id');
    window.location.href = "my-page.php?id="+id;
});