hi

i design websit to view images


i want when admin click on the image image will be deleted


how i do that


??

this my code

<head>
<script type="text/javascript" >
function vvvv($id,$im)
{

if(confirm("are you sure want delet this imagej?"));

$b=true

if($b)
{
<?php


mysql_connect ('localhost', 'root');
mysql_select_db("pickapic");
$myquery="Delete FROM photo WHERE Pid=$id";
mysql_query($myquery);

?>

}


}

</script>
</head>

<body>







<?php

print("<table width=40% border=0 align=center>");

 mysql_connect ('localhost', 'root');
mysql_select_db("pickapic");

$result2= mysql_query("SELECT Pname FROM photo");
$result = mysql_query("SELECT Pid , link FROM photo");
$count=0;

while($row = mysql_fetch_array($result))
  {
  if ($count==0)
 print("<tr>");
 $image=$row["link"];
 $id=$row["link"];
 
 print ("<td><img src=\"file:///C|/xampp/htdocs/PickaPic/admin/img/$image \" width=\"150\" height=\"150\" border=\"0\" onClick=\"vvvv('$id','$image')\"; ></td>");

 $count=$count+1;
 
 if($count == 5 )
 {
 print("</tr>");
 print("<tr>");
 
for($i=0; $i<5 ; $i=$i+1)
{
$row2= mysql_fetch_array($result2);
$name1=$row2["Pname"];
print("<td><div align=\"center\"><span class=\"style6\"> $name1  </span></div></td>");


}
print("</tr>");
 $count=0;
 }
 

  }
 
  print("</table>");
  
 
?>


</body>

</html>

thx :):):)

its easier to help when you explain what you want in more detail.

hi kkeith

i explain it


and i have code i mix php with java script and it work as will

if that mistake

how i correct it please

:(
:(
:(

what are the smilies for?

to tell i still have problem


plzzz i try many times

i dont sleep for 2 days

today is last day that means i must finish it today

i am really sad

is it outputting the images ok, is the delete function the only thing you are having trouble with.

i typed this up for you. i only fixed the delete images part and copied the rest of your code.

try it, and tell me if there are errors.

<?php

//Set page name
$thispage = 'index.php';

//Fill in database info
$host = 'localhost';
$user = 'root';
$pass = '';
$db   = 'pickapic';

$con = mysql_connect($host,$user,$pass) or die('Could not connect');
mysql_select_db($db) or die('Error: Could not select database');

if (isset($_GET['do'])) {
	$do = $_GET['do'];
	switch($do) {
		case "delete":
			if (isset($_GET['id'])) {
				$id    = mysql_real_escape_string($_GET['id']);
				$sql   = "DELETE FROM `photo` WHERE `Pid` = " . $id;
				$query = mysql_query($sql) or die('Error: ' . mysql_error());
			}
		break;
	}
}

$table  = '<table width="40%" border="0" align="center">';

$sql1   = "SELECT `Pname` FROM `photo`";
$sql2   = "SELECT `Pid`,`link` FROM `photo`";
$query1 = mysql_query($sql1);
$query2 = mysql_query($sql2);
$count  = 0;
while ($row = mysql_fetch_assoc($query1)) {
	if ($count == 0) {
		$table .= '<tr>';
	}
	$image = $row['link'];
	$id    = $row['link'];
	$table .= '<td><img src="file:///C|/xampp/htdocs/PickaPic/admin/img/' . $image . '" width="150" height="150" border="0" onClick="vvvv(\'' . $id . '\');" /></td>';
	$count++;
	if ($count == 5) {
		$table .= '</tr>';
		$table .= '<tr>';
		for ($i = 0; $i < 5; $i++) {
			$row2 = mysql_fetch_assoc($query2);
			$name1 = $row2['Pname'];
			$table .= '<td><div align="center"><span class="style6"> ' . $name1 . ' </span></div></td>';
		}
		$table .= '</tr>';
		$count  = 0;
	}
}
$table .= '</table>';

mysql_close($con);

?>
<html>
<head>
<title></title>
<script type="text/javascript">
function vvvv(id) {
	if (confirm("Are you sure you want to delete this image?")) {
		window.location = '<?php echo $thispage;?>?do=delete&id='+id;
	}
}
</script>
</head>
<body>
<?php echo $table;?>
</body>
</html>

is this is personal project?

i was just curious

hi

in my previouse code the alert appare

but code to delet image from database dosn excute

i mean image didnt deleted

no , i have another in my add photo code


alert dont appare i dont know why


??

can u fix it plzz?

that was really confusing. are you saying that my confirm javascript didn't execute and the image was not deleted.

or are you talking about another code.

:)


i said in my above code

alert appare but data dosnt remove from my database

in my delet code i think the error when i pass variable as prameter and recive it

becoz when i give $id value inside my function data removed

but when i recive $id as pramater
data dosnt remove

i have another code for adding

alert dosnot appare

but data add to my data base


but now i care much about my delet code

i have no idea what the problem is. i would have to see it for myself to maybe find the error. i didn't see anything wrong with my code.

can i send my code to u

and sorry coz i late

i guess you can send it to me. i won't be able to get to it until later today.

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1


this error appare

is this is personal project?

i was just curious

yes its

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.