index.php
<?php
include './search_image.php';
$obj_image = new Image();
$obj_im = new Image();
if (@$_POST['Submit']) {
$obj_image->image_name=str_replace("'", "''", $_POST['txt_image_name']);
$obj_image->Insert_into_image();
$data_image=$obj_image->get_all_image_list();
$row=mysql_num_rows($data_image);
}
function reply_click(clicked_id)
{
$obj_im->image1=clicked_id;
$obj_im->update_rank();
}
?>
<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Home</title>
</head>
<body bgcolor=cyan>
<script>
window.location.hash="no-back-button";
window.location.hash="Again-No-back-button"; //again because google chrome don't insert first hash into history
window.onhashchange=function(){window.location.hash="no-back-button";}
</script>
<center><h1>WEB IMAGE RERANKING</H1></center>
<center>
<table border=0 cellspacing=10>
<th><a href="index.php" target="right">HOME</th>
<th><a href="admin.php" target"=right">ADMIN</th>
<form method="post" enctype="multipart/form-data">
<tr>
<th width="50%">Enter Image name for search</th>
<td width="50%"><input type="text" name="txt_image_name"></input></td>
</tr>
<tr>
<td width="50%"><input type="submit" name="Submit" value="Submit"></input></td>
</tr>
</table>
</form>
</center>
<?php
if ($row!=0) {
?>
<center>
<form method="post" enctype="multipart/form-data">
<table width="30%" border="0">
<?php
while ($data= mysql_fetch_assoc($data_image)) {
?>
<tr>
<a href=# class="gallery" id="<?php echo $data['image']; ?>" onClick="reply_click(this.id)"> <img src="images/<?php echo $data['image']; ?>" width="400px" height="200px" ></a>
</tr>
<?php
}
?>
</table>
</form>
</center>
<?php
}
?>
</body>
</html>
search_image.php
<?php
include 'db_connection.php';
class Image
{
var $image_id,
$image_name,
$image;
function Insert_into_image()
{
}
function get_all_image_list()
{
$query = "select *from stor_image where img_name='$this->image_name'";
$result = mysql_query($query);
return $result;
}
function update_rank()
{
$query2 ="select rank from stor_image where image = '$this->image1' ";
$result1 = mysql_query($query2);
$r1 = $result1+1;
$query1 ="UPDATE stor_image SET rank = '$r1' WHERE image='$this->image1' ";
if (mysql_query($query1)) {
echo "<script language='javascript' type='text/javascript'> alert('rank updated') </script>";
} else {
echo "<script language='javascript' type='text/javascript'>alert('rank updated')</script>";
}
}
}
?>
if the "function reply_click(clicked_id)" is working with in the tag and it is help full to to get clicked image name. But this function can not work with in php tag. how to send the image name value is "clicked_id" to search_image.php for updating the rank of the image. Thank you