Jump to content

Recommended Posts

hey i am trying to delete this row ... for some reason this does nt carry my $id over to the sql query ... here is the code ..

 

deleteband is the value/name of the submit

 


$id = $_POST['id'];
$sid = $_POST['sid'];

if ( $_POST['deleteband'] ) {


$query = "DELETE FROM bands WHERE id = '$id' ";
$result = mysql_query($query);

header("Location: ../view_bands.php");

}


 

 

Link to comment
https://forums.phpfreaks.com/topic/154929-solved-help-with-sql-delete/
Share on other sites

here is the form ..

 


<div id="deleteband" style="display:none">

Please choose a band to delete. <br>
Remember !! This CAN NOT be undone !!
<p><br>

<form method='post' action='scripts/delete.php' enctype="multipart/form-data">


<select class="FMaddSHOW" name="id">	
<option selected="selected">What Band ?</option>
<?
// Get records from database (table "name_list").
$list=mysql_query("select * from bands where userid = ". $_SESSION['id']);

// Show records by while loop.
while($row_list=mysql_fetch_assoc($list)){
?>
<option value="<? echo $row_list['id']; ?>"><? echo $row_list['b_name']; ?></option>
<?
// End while loop.
}
?>
</select>

<p>

Are you sure you want to delete this band ? <br>
Are you 100% totally and surely for the most part sure ?
<p><br>

<input type="hidden" name="deleteband" value="Delete Band">
<input type="image" src="images/b_delete_band_small.png" name="deleteband" value="Delete Band"> <br>

</form>

</div>


 

The name is in the select :

 

<select class="FMaddSHOW" name="id">

 

So the value of each option is what I am looking to retrieve ...

 

here is the code to my whole delete script ..

 

<?php 


include('settings.php');



$id = $_POST['id'];
$sid = $_POST['sid'];


$id = $_GET['id'];
$delete = $_GET['delete'];



if ( $_POST['deleteshow'] ) {

$query = "DELETE FROM shows WHERE sid = ('$sid')";
$result = mysql_query($query);

header("Location: ../view_shows.php");

} 



if ( isset($_POST['deleteband']) ) {


$query = "DELETE FROM bands WHERE id = '$id' ";
$result = mysql_query($query);

header("Location: ../view_bands.php");

}




if ( $_POST['deletetour'] ) {

$query = "DELETE FROM tours WHERE id = ('$id')";
$result = mysql_query($query);

header("Location: ../view_tours.php");

}


if ( $_POST['deletetourdate'] ) {

$query = "DELETE FROM tourdates WHERE id = ('$id')";
$result = mysql_query($query);

header("Location: ../view_tours.php");

}


if ( $_POST['deletecontact'] ) {

$query = "DELETE FROM contacts WHERE id = ('$id')";
$result = mysql_query($query);

header("Location: ../view_contacts.php");

}


if ( $delete == 'deletefan') {


$query = "DELETE FROM fans_email WHERE id = ('$id')";
$result = mysql_query($query);

header("Location: ../view_fans.php");

}





?>


 

 

 

I think the problem might be that you have two fields in your form called deleteband. If the browser uses the second one then because the field is of type image deleteband_x and deleteband_y will be set instead of deleteband.

 

Change the name="" attribute of your image field. 

are you talking about the HIDDEN tag named "deleteband" and then the IMAGE submit "deleteband" ?

 

This is because IE does not accept images as submit buttons .. I have it this way on all my other forms and it seams to work ...

 

 

if you look at the code from my above post, its the full DELETE script, which has multiple delete queries ..

 

When I put an echo "$id" at the top after the $_POST and $_GETS its post the $id just fine ...

 

Its when I place the $id inside the mysql query it will not work .. it wont even work anywhere inside the if statement ...

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.