Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Topics

Recent Status Updates

View All Updates

- - - - -

view, delete images in database

images delete images

  • Please log in to reply
1 reply to this topic

#1 troublephp


    CC Lurker

  • Just Joined
  • Pip
  • 1 posts
  • Programming Language:Java, PHP, JavaScript, Visual Basic .NET

Posted 25 October 2012 - 12:28 AM

Hello everybody,

I am working on content managemet system for my website and i having a little trouble with viewing images in a table that has other contents say id.

I need a table that can view multiple images from a table in the database and then a checkbox around all the images for deleting. So should the checkbox be selected, and a button delete clicked, then the images can be deleted.

here is my code:

include 'file_constants.php';
// Connect to server and select databse.
mysql_connect("$host", "$user", "$pass")or die("cannot connect");
mysql_select_db("$db")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name";
//where do i place the content type for the images?
header('Content-type: image/jpg');
<table width="400" border="0" cellspacing="1" cellpadding="0">
<td><form name="form1" method="post" action="">
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<td bgcolor="#FFFFFF">&nbsp;</td>
<td colspan="4" bgcolor="#FFFFFF"><strong>Delete multiple rows in mysql</strong> </td>
<td align="center" bgcolor="#FFFFFF">#</td>
<td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Images</strong></td>
<td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td>
<td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td>
<td bgcolor="#FFFFFF"><? echo $rows['image']; ?></td>
<td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td>
// Check if delete button active, start this
$del_id = $checkbox[$i];
$sql = "DELETE FROM $tbl_name WHERE id='$del_id'";
$result = mysql_query($sql);
// if successful redirect to delete_multiple.php
echo "<meta http-equiv=\"refresh\" content=\"0;URL=del.php\">";

Where do i place the header content for the images?
  • 0

#2 Orjan


    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 25 October 2012 - 03:47 AM

nowhere in this file. Read our tutorial http://forum.codecal...ay-your-images/ regarding this. you should create a separate file just returning the file content, nothing more, having header for content type. then you call this file with an id parameter to get the picture you want in the file you show now.
  • 0

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.

Also tagged with one or more of these keywords: images, delete images

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download