I am writing a plugin, I did everything I needed.

global $wpdb; $myrows = $wpdb->get_results( "SELECT id, url FROM wp_jslider" ); $rowcount = $wpdb->num_rows; if ($rowcount==0) { echo 'No images, please upload'; } else { for ($i=0; $i < $rowcount; $i++) { echo '<div name="id_'.$myrows[$i]->id.'" class=""><img src="'.$myrows[$i]->url.'" width="100" height="50"><a name="del_'.$myrows[$i]->id.'" href="">x</a></div>'; } } 

But I can not delete a specific photo. Can anyone help? And tell me, I did everything right during the sampling, but I would not want to violate security

  • I in your code do not see the mention of the operator delete . By the way, global is a vile evil and very real bad practics - rjhdby
  • Add a wordpress tag, please - vp_arth
  • Rjhdby, The fact is that I do not know how to implement it. vp_arth, Where, why? - Anry Reese

2 answers 2

And tell me, I did everything right during the sampling, but I would not want to violate security

Wrong. No need to climb into the base. It is necessary to use the API.

In this case, wp_delete_attachment

    General deletion case, $ wpdb:

     $wpdb->delete('your_table', array('your_image_id' => $id), array('%d'));