Jump to content

[SOLVED] PLEASEEEE HELP


andrew_biggart

Recommended Posts

CAN ANYONE SPOT THE PHP ERROR IN THE SYNTAX or why this wouldnt work ????

 

<?php

include("config.php");

if(!isset($_POST['delete'])){

$sql="SELECT * FROM biggart_members";

$result=mysql_query($sql);

 

$count=mysql_num_rows($result);

?><table width="400" border="0" cellspacing="1" cellpadding="0">

<tr>

<td><form name="action" id="action" method="post" action="<?=$_SERVER['PHP_SELF']?>">

<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">

<tr>

<td bgcolor="#FFFFFF"> </td>

<td colspan="4" bgcolor="#FFFFFF"><strong>Delete multiple rows in mysql</strong> </td>

</tr>

<tr>

<td align="center" bgcolor="#FFFFFF">#</td>

<td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td>

<td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td>

<td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td>

<td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td>

<td align="center" bgcolor="#FFFFFF"><strong>Username</strong></td>

</tr>

<?php

while($rows=mysql_fetch_assoc($result)){

?>

<tr>

<td align="center" bgcolor="#FFFFFF"><input type="checkbox" name="<?=$row[user_id]?>" id="<?=$row[user_id]?>" value="<?=$row[user_id]?>" /></td>

<td bgcolor="#FFFFFF"><?php echo $rows['user_id']; ?></td>

<td bgcolor="#FFFFFF"><?php echo $rows['name']; ?></td>

<td bgcolor="#FFFFFF"><?php echo $rows['lastname']; ?></td>

<td bgcolor="#FFFFFF"><?php echo $rows['email']; ?></td>

<td bgcolor="#FFFFFF"><?php echo $rows['username']; ?></td>

 

</tr>

<?php

}

?>

<tr>

<td colspan="5" align="center" bgcolor="#FFFFFF"><input type="submit" name="perform" id="perform" value="Delete Selected" /> </td>

</tr>

<?php

if($_POST['perform']) {

 

foreach($_POST as $user_id) { // This will loop through the checked checkboxes

 

mysql_query("DELETE FROM biggart_members WHERE user_id='$user_id' LIMIT 1");

 

}

}

mysql_close();

?>

</table>

</form>

</td>

</tr>

</table>

</div>

 

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/107683-solved-pleaseeee-help/
Share on other sites

<?php
include("config.php");
if(!isset($_POST['delete'])){
$sql="SELECT * FROM biggart_members";
$result=mysql_query($sql);

$count=mysql_num_rows($result);
?><table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td><form name="action" id="action" method="post" action="<?=$_SERVER['PHP_SELF']?>">
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#FFFFFF"> </td>
<td colspan="4" bgcolor="#FFFFFF"><strong>Delete multiple rows in mysql</strong> </td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF">#</td>
<td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Username</strong></td>
</tr>
<?php
while($rows=mysql_fetch_assoc($result)){
?>
<tr>
<td align="center" bgcolor="#FFFFFF">
<input type="checkbox" name="<?=$row[user_id]?>" id="<?=$row[user_id]?>" value="<?=$row[user_id]?>" /></td>
<td bgcolor="#FFFFFF"><?php echo $rows['user_id']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['name']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['lastname']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['email']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['username']; ?></td>

</tr>
<?php
}
?>
<tr>
<td colspan="5" align="center" bgcolor="#FFFFFF"><input type="submit" name="perform" id="perform" value="Delete Selected" /> </td>
</tr>
<?php
if($_POST['perform']) {

foreach($_POST as $user_id) { // This will loop through the checked checkboxes

mysql_query("DELETE FROM biggart_members WHERE user_id='$user_id' LIMIT 1"); 

}
}
}
mysql_close();
?>
</table>
</form>
</td>
</tr>
</table>   
</div>

CAN ANYONE SPOT THE PHP ERROR IN THE SYNTAX or why this wouldnt work ????

 

<?php

include("config.php");

if(!isset($_POST['delete'])){

$sql="SELECT * FROM biggart_members";

$result=mysql_query($sql);

 

$count=mysql_num_rows($result);

?><table width="400" border="0" cellspacing="1" cellpadding="0">

<tr>

<td><form name="action" id="action" method="post" action="<?=$_SERVER['PHP_SELF']?>">

<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">

<tr>

<td bgcolor="#FFFFFF"> </td>

<td colspan="4" bgcolor="#FFFFFF"><strong>Delete multiple rows in mysql</strong> </td>

</tr>

<tr>

<td align="center" bgcolor="#FFFFFF">#</td>

<td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td>

<td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td>

<td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td>

<td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td>

<td align="center" bgcolor="#FFFFFF"><strong>Username</strong></td>

</tr>

<?php

while($rows=mysql_fetch_assoc($result)){

?>

<tr>

<td align="center" bgcolor="#FFFFFF"><input type="checkbox" name="<?=$row[user_id]?>" id="<?=$row[user_id]?>" value="<?=$row[user_id]?>" /></td>

<td bgcolor="#FFFFFF"><?php echo $rows['user_id']; ?></td>

<td bgcolor="#FFFFFF"><?php echo $rows['name']; ?></td>

<td bgcolor="#FFFFFF"><?php echo $rows['lastname']; ?></td>

<td bgcolor="#FFFFFF"><?php echo $rows['email']; ?></td>

<td bgcolor="#FFFFFF"><?php echo $rows['username']; ?></td>

 

</tr>

<?php

}

?>

<tr>

<td colspan="5" align="center" bgcolor="#FFFFFF"><input type="submit" name="perform" id="perform" value="Delete Selected" /> </td>

</tr>

<?php

if($_POST['perform']) {

 

foreach($_POST as $user_id) { // This will loop through the checked checkboxes

 

mysql_query("DELETE FROM biggart_members WHERE user_id='$user_id' LIMIT 1");

 

}

}

mysql_close();

?>

</table>

</form>

</td>

</tr>

</table>

</div>

 

 

Thanks in advance

 

first you already posted this didnt you? second put your code in

 

yup...missing close bracket at the end...start indenting, it will make your life SO much easier:

 

<?php
include("config.php");
if(!isset($_POST['delete'])){
  $sql="SELECT * FROM biggart_members";
  $result=mysql_query($sql);

  $count=mysql_num_rows($result);
?><table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td><form name="action" id="action" method="post" action="<?=$_SERVER['PHP_SELF']?>">
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#FFFFFF"> </td>
<td colspan="4" bgcolor="#FFFFFF"><strong>Delete multiple rows in mysql</strong> </td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF">#</td>
<td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Username</strong></td>
</tr>
<?php
  while($rows=mysql_fetch_assoc($result)){
?>
<tr>
<td align="center" bgcolor="#FFFFFF"><input type="checkbox" name="<?=$row[user_id]?>" id="<?=$row[user_id]?>" value="<?=$row[user_id]?>" /></td>
<td bgcolor="#FFFFFF"><?php echo $rows['user_id']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['name']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['lastname']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['email']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['username']; ?></td>

</tr>
<?php
  }
?>
<tr>
<td colspan="5" align="center" bgcolor="#FFFFFF"><input type="submit" name="perform" id="perform" value="Delete Selected" /> </td>
</tr>
<?php
  if($_POST['perform']) {

    foreach($_POST as $user_id) { // This will loop through the checked checkboxes

      mysql_query("DELETE FROM biggart_members WHERE user_id='$user_id' LIMIT 1");

    }
  }
mysql_close();
?>
</table>
</form>
</td>
</tr>
</table>
<?php
}
?>

you changed a few things from the code I gave you before. you changed your submit button name but didn't change the check up top.

 

<?php
include("config.php");
if(!isset($_POST['perform'])){
$sql="SELECT * FROM biggart_members";
$result=mysql_query($sql);

$count=mysql_num_rows($result);
?><table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td><form name="action" id="action" method="post" action="<?=$_SERVER['PHP_SELF']?>">
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#FFFFFF"> </td>
<td colspan="4" bgcolor="#FFFFFF"><strong>Delete multiple rows in mysql</strong> </td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF">#</td>
<td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Username</strong></td>
</tr>
<?php
while($rows=mysql_fetch_assoc($result)){
?>
<tr>
<td align="center" bgcolor="#FFFFFF"><input type="checkbox" name="<?=$row[user_id]?>" id="<?=$row[user_id]?>" value="<?=$row[user_id]?>" /></td>
<td bgcolor="#FFFFFF"><?php echo $rows['user_id']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['name']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['lastname']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['email']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['username']; ?></td>

</tr>
<?php
}
?>
<tr>
<td colspan="5" align="center" bgcolor="#FFFFFF"><input type="submit" name="perform" id="perform" value="Delete Selected" /> </td>
</tr>
<?php
} else {

foreach($_POST as $user_id) { // This will loop through the checked checkboxes

mysql_query("DELETE FROM biggart_members WHERE user_id='$user_id' LIMIT 1");

}
}
mysql_close();
?>
</table>
</form>
</td>
</tr>
</table>
</div>

 

Ray

ok thanks for that i am no longer getting a blanc screen but the code isnt doing what i wnat it to do !!

 

All i want is to be able to delte users by checking a checkbox and clicking delete!

does anyone have any ideas why this code would not work???

 

Thanks again sorry if im pissing any1 off im new to this forum

 

<?php
include("config.php");
if(!isset($_POST['delete'])){
$sql="SELECT * FROM biggart_members";
$result=mysql_query($sql);

$count=mysql_num_rows($result);
?><table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td><form name="action" id="action" method="post" action="<?=$_SERVER['PHP_SELF']?>">
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#FFFFFF"> </td>
<td colspan="4" bgcolor="#FFFFFF"><strong>Delete multiple rows in mysql</strong> </td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF">#</td>
<td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Username</strong></td>
</tr>
<?php
while($rows=mysql_fetch_assoc($result)){
?>
<tr>
<td align="center" bgcolor="#FFFFFF">
<input type="checkbox" name="<?=$row[user_id]?>" id="<?=$row[user_id]?>" value="<?=$row[user_id]?>" /></td>
<td bgcolor="#FFFFFF"><?php echo $rows['user_id']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['name']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['lastname']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['email']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['username']; ?></td>

</tr>
<?php
}
?>
<tr>
<td colspan="5" align="center" bgcolor="#FFFFFF"><input type="submit" name="perform" id="perform" value="Delete Selected" /> </td>
</tr>
<?php
if($_POST['perform']) {

foreach($_POST as $user_id) { // This will loop through the checked checkboxes

mysql_query("DELETE FROM biggart_members WHERE user_id='$user_id' LIMIT 1"); 

}
}
}
mysql_close();
?>
</table>
</form>
</td>
</tr>
</table>

How many time you going to change it. This works just copy and paste it.

<?php
include("config.php");
$table = "biggart_members";
if(!isset($_POST['perform'])){
$sql="SELECT * FROM $table";
$result=mysql_query($sql);

$count=mysql_num_rows($result);
?><table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td><form name="action" id="action" method="post" action="<?=$_SERVER['PHP_SELF']?>">
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#FFFFFF"> </td>
<td colspan="4" bgcolor="#FFFFFF"><strong>Delete multiple rows in mysql</strong> </td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF">#</td>
<td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Username</strong></td>
</tr>
<?php
while($rows=mysql_fetch_assoc($result)){
?>
<tr>
<td align="center" bgcolor="#FFFFFF"><input type="checkbox" name="checkbox[]" id="<?=$rows['user_id']?>" value="<?=$rows['user_id']?>" /></td>
<td bgcolor="#FFFFFF"><?php echo $rows['user_id']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['name']; ?></td> <!-- -->
<td bgcolor="#FFFFFF"><?php echo $rows['lastname']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['email']; ?></td> <!--  -->
<td bgcolor="#FFFFFF"><?php echo $rows['username']; ?></td>

</tr>
<?php
}
?>
<tr>
<td colspan="5" align="center" bgcolor="#FFFFFF"><input type="submit" name="perform" id="perform" value="Delete Selected" /> </td>
</tr>
<?php
} else {

foreach($_POST['checkbox'] as $user_id) { // This will loop through the checked checkboxes
$sql = "DELETE FROM $table WHERE user_id='$user_id' LIMIT 1";
echo $sql."<br />";
mysql_query($sql) or die(mysql_error());

}
}
mysql_close();
?>
</table>
</form>
</td>
</tr>
</table>
</div>

 

Ray

I'm pretty sure that craygo's code works.  As for you being new to the forums, let me give you some hints so you can get better help:

 

1) Don't type in caps.  It's annoying.

2) Marquees are equally annoying.

3) Typing coherently works wonders.  Inside of typing "liek dis", type properly so you can properly ask a question.

4) Don't just sit there and wait for a response.  At least try something while you wait.

 

Following those tips, even if you only follow one or two of them, will help a lot.

Thanks so much ray you are a legend it works yes!!!

 

But yes the dreaded but, it messes with my layout so ive tried to add it to my normal tables now and now im getting a syntax error can anyone spot it ????? please and thanks for everyones help especially ray aka legend!!

 

	<?php
include("config.php");
$table = "biggart_members";
if(!isset($_POST['perform'])){
$sql="SELECT * FROM $table";
$result=mysql_query($sql);

$count=mysql_num_rows($result);
?>
<br/>
<form name="action" id="action" method="post" action="<?=$_SERVER['PHP_SELF']?>">
<table class= "select_header"width="400" border="0" cellspacing="0" cellpadding="4">
<tr>
<td style="width: 370px" class="select_header">Admin Section </td>
</tr>
</table>
<br/>
<table class= "select_myebaygrey"width="400" border="0" cellspacing="0" cellpadding="4">
<tr>
<td style="width: 370px">View all users</td>
</tr>
</table>
<br/>
<table class= "select_myebaygrey"width="400" border="0" cellspacing="0" cellpadding="4">
<tr>
<td style="width: 30px" class="style28">Userid </td>
<td style="width: 69px" class="style28">First name</td>
<td style="width: 102px" class="style28">Email</td>
<td style="width: 107px" class="style28">Username</td>
<td style="width: 136px" class="style28">Avatar</td>
<td class="style28">Delete User</td>
</tr>
</table>
<table class= "select_main"width="400" border="0" cellspacing="0" cellpadding="4">
<tr>
<td style="width: 33px" ><? echo $rows['user_id']; ?></td>
<td style="width: 94px" ><? echo $rows['name']; ?></td>
<td style="width: 97px" ><? echo $rows['email']; ?></td>
<td style="width: 86px" ><? echo $rows['username']; ?></td>
<td style="width: 122px" ><? echo "<img src='avatars/". $rows['user_avatar'] . "' style='width:50px; height:50px;' />";?></td>
<td align="center"><input type="checkbox" name="checkbox[]" id="<?=$rows['user_id']?>" value="<?=$rows['user_id']?>" /></td>
</tr>
</table>
<?php
}
?>
<table>
<tr>
<td colspan="5" align="right" ><input type="submit" name="perform" id="perform" value="Delete Selected" /> </td>
</tr>
</table>
<?php
} else {

foreach($_POST['checkbox'] as $user_id) { // This will loop through the checked checkboxes
$sql = "DELETE FROM $table WHERE user_id='$user_id' LIMIT 1";
echo $sql."<br />";
mysql_query($sql) or die(mysql_error());

}
}
mysql_close();
?>
</form>

I'm pretty sure that craygo's code works.  As for you being new to the forums, let me give you some hints so you can get better help:

 

1) Don't type in caps.  It's annoying.

2) Marquees are equally annoying.

3) Typing coherently works wonders.  Inside of typing "liek dis", type properly so you can properly ask a question.

4) Don't just sit there and wait for a response.  At least try something while you wait.

 

Following those tips, even if you only follow one or two of them, will help a lot.

 

5) Use code tags

6) don't make ambiguous titles like "PLEASEEEE HELP"

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.