hi every one


i find this code

and i read this descreption about it :

code to call function after u click on it

<a href="<?php $_SERVER['PHP_SELF']?>?type=del">
<img src="del.png"/>
</a>

my qidtion : can i know any information about image when i call function using this code

i mean can i know id of the image which user click on it

if my image jpg can i use it with this code

how i use it ??

this part3

if($_GET['type']=="del")
{

//call functions

}

how i use it


:confused:

Recommended Answers

All 4 Replies

The first code is setting the name of the image. Are you keeping your images in a Link database? If you are you can query your db with the $_GET:

$imagename = $_GET['type'];
$imageinfo = mysql_query("SELECT ID FROM Images WHERE Image_Name = '".$imagename."'") or die(mysql_error());
$info=mysql_fetch_array($imageinfo);
$imageid = $info['ID'];

Not really sure what your looking for but that is how you can see the image information. If your wanting to view what user clicked on a specific image thats just another table and a little more code.
Table Image Click:
ID, ImageID, Userid, any other info you want.

//include the code above
$ImageClick = mysql_query("INSERT INTO Image_Click (ImageID, Userid, other fields) VALUES (`".$imageid."`, `".$_SESSION['userid']."`, `".$otherfields."`)") or die(mysql_error());

Then you can query this table and view the users that have clicked on what images and possibly the time or any other info you want to view.

hi

proffessorPC

is that mean i can do that "

<?php

$imageID = $_GET['type'];
mysql_query("DELETE FROM Images WHERE picID= '".$imageID."'") or die(mysql_error());
?>

:
:

code

:
:

<?php

:
:

<a href="<?php $_SERVER['PHP_SELF']?>?type=$row["picId"]">
<img src="$row["link"]"/>
</a>
:
:

?>

is this code will delete image after user clicked on it

try using this in the image href

echo "<a href='pagename.php?type=$row['PicId']'>";

Here is the idea.
Pass the id of the image in the query string. <a href='deleteimage.php?id=4'>Delete now </a> Then, in deleteimage.php, get the id, and delete the image.

//connection
$id = mysql_real_escape_string($_GET['id']);
$q = "delete from table where imageid = '$id'"; // if you are storing the image in the table (which is a very bad idea)
mysql_query($q);
//redirect the user back to the image display screen
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.