473,811 Members | 4,216 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Delete MySql Rows Problem

imarkdesigns
46 New Member
Hello everyone.. a newbie programmer here wants to ask why is my codes for deleting rows from my databse won't work.... seems that this codes spread to the net and no one refuse to correct it...

can someone correct this...

[PHP] <!-- Editable Area -->
<?php

include ("../dbconnection/connect.php");

$tbl_name="sche dule"; // Table name

mysql_connect(" $host", "$username" , "$password" )or die("cannot connect");
mysql_select_db ("$db_name") or die("cannot select DB");

$sql="SELECT * FROM $tbl_name";
$result=mysql_q uery($sql);

$count=mysql_nu m_rows($result) ;

?>

<?php
while($rows=mys ql_fetch_array( $result)){
?>
<form name="form1" action="" method="post" enctype="multip art/form-data">
<table id="alter_rows " align="center" cellpadding="0" cellspacing="0" >
<tr>
<td align="center" class="adminche ckbox"> <input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"> </td>
<td class="admindat e"> <? echo $rows['date']; ?> </td>
<td class="admintim e"> <? echo $rows['id']; ?> </td>
<td class="admineve nts"> <? echo $rows['events']; ?> </td>
<td class="adminven ue"> <? echo $rows['venue']; ?> </td>
<td class="adminloc ations"> <? echo $rows['locations']; ?> </td>
</tr>

</table>
<?php
}
?>
<!-- Editable Area -->
<table cellpadding="0" cellspacing="0" >
<tr>
<td><input name="delete" id="delete" type="submit" value="Delete Schedule" /></td>
</tr>
</table>
<?
// Check if delete button active, start this

//$delete = $_REQUEST['delete'];
//
if($delete){
for($i=0;$i<$co unt;$i++){
$del_id = $checkbox[$i];
$sql = "DELETE FROM schedule WHERE id='$del_id' LIMIT 1";
$result = mysql_query($sq l);
}

// if successful redirect to delete_multiple .php
if($result){
echo "<meta http-equiv=\"refresh \" content=\"0;URL =deleterow.php\ ">";
}
}
mysql_close();
?>
</form>[/PHP]

when a DELETE button hits nothing happens...
Jul 25 '07 #1
4 2215
r035198x
13,262 MVP
Hello everyone.. a newbie programmer here wants to ask why is my codes for deleting rows from my databse won't work.... seems that this codes spread to the net and no one refuse to correct it...

can someone correct this...

#-------

<!-- Editable Area -->
<?php

include ("../dbconnection/connect.php");

$tbl_name="sche dule"; // Table name

mysql_connect(" $host", "$username" , "$password" )or die("cannot connect");
mysql_select_db ("$db_name") or die("cannot select DB");

$sql="SELECT * FROM $tbl_name";
$result=mysql_q uery($sql);

$count=mysql_nu m_rows($result) ;

?>

<?php
while($rows=mys ql_fetch_array( $result)){
?>
<form name="form1" action="" method="post" enctype="multip art/form-data">
<table id="alter_rows " align="center" cellpadding="0" cellspacing="0" >
<tr>
<td align="center" class="adminche ckbox"> <input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"> </td>
<td class="admindat e"> <? echo $rows['date']; ?> </td>
<td class="admintim e"> <? echo $rows['id']; ?> </td>
<td class="admineve nts"> <? echo $rows['events']; ?> </td>
<td class="adminven ue"> <? echo $rows['venue']; ?> </td>
<td class="adminloc ations"> <? echo $rows['locations']; ?> </td>
</tr>

</table>
<?php
}
?>
<!-- Editable Area -->
<table cellpadding="0" cellspacing="0" >
<tr>
<td><input name="delete" id="delete" type="submit" value="Delete Schedule" /></td>
</tr>
</table>
<?
// Check if delete button active, start this

//$delete = $_REQUEST['delete'];
//
if($delete){
for($i=0;$i<$co unt;$i++){
$del_id = $checkbox[$i];
$sql = "DELETE FROM schedule WHERE id='$del_id' LIMIT 1";
$result = mysql_query($sq l);
}

// if successful redirect to delete_multiple .php
if($result){
echo "<meta http-equiv=\"refresh \" content=\"0;URL =deleterow.php\ ">";
}
}
mysql_close();
?>
</form>


------#

when a DELETE button hits nothing happens...
I'm going to have to copy this to the PHP forum as well.
Jul 25 '07 #2
dafodil
392 Contributor
I'm going to have to copy this to the PHP forum as well.
I posted on my reply on the php forum please check it....
Jul 25 '07 #3
r035198x
13,262 MVP
I posted on my reply on the php forum please check it....
And that thread is found here.
Jul 25 '07 #4
imarkdesigns
46 New Member
thanks guys...

and it seems working on the live site not on the localhost...???

um, this crazy little something... haha..
Jul 25 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
37029
by: NotGiven | last post by:
I'd like to delete a record and all its children records at one time. How do I do that? Can you, in one SQL statement, delete from table 1 where id = 3 delete from table 2 where id = 12 delete from table 3 where id = 12 ......
4
5309
by: Chris | last post by:
Hi, sorry to post OT but i cant find the MySQL newsgroup, however i am hoping to pick up on some expert advice from php/mysql gurus here. I'm having some trouble performing a delete across two tables. The tables i have are: questionnaires (id, name); questionnaire_questions (questionnaires_id, id, name, qf_type)
0
6462
by: Gordon | last post by:
I have 2 tables t and t1. In this case, t1 is a copy of t. I want to delete rows from t1 based on criteria on the t table and a relationship between t ad t1 (in this case the id column). In the results below, I would think that the delete should have deleted row 1 {1 5 me) and not row 3 (1 5 they) when I run this statement delete t1 from t, t1 where t.id = t1.id and t.id=1 and t.name = 'me'; Any ideas on why row 2 is deleted?
0
2397
by: Vikram Vaswani | last post by:
Hi all, I have the following two tables: mysql> SELECT * FROM clients; +-----+-----------------------------+ | cid | cname | +-----+-----------------------------+ | 101 | JV Real Estate | | 102 | ABC Talent Agency |
2
16744
by: michael | last post by:
Gotta post because this is driving me nuts. Trying to DELETE orphans. I can successfully: SELECT GroupID FROM Groups LEFT JOIN Users ON UsersID = UserID WHERE UsersID IS NULL; but when I try: DELETE FROM Groups LEFT JOIN Users ON UsersID = UserID WHERE UsersID
1
8911
by: Andrew DeFaria | last post by:
I created the following .sql file to demonstrate a problem I'm having. According to the manual: If |ON DELETE CASCADE| is specified, and a row in the parent table is deleted, then InnoDB automatically deletes also all those rows in the child table whose foreign key values are equal to the referenced key value in the parent row. However:
3
2404
by: Richard Marsden | last post by:
Here's another strange error I'm getting when using ODBC to access MySQL. This time ODBC is being more informative, although all the documentation I've looked at, claims that the function in question (SQLSetPos) should not return the error! I have a result set that has been opened for update. I am trying to delete the current row with a call to SQLSetPos: rc = SQLSetPos( hStmt, nRow, SQL_DELETE, SQL_LOCK_NO_CHANGE );
9
2802
by: Dejan | last post by:
Hy, Sorry for my terreble english I have this simple code for deleting rows in mysql table... Everything works fine with it. So, what do i wanna do...: my sql table looks something like this: id Name Surname pictr0 picrt1 pictr2 pictr3
6
2872
imarkdesigns
by: imarkdesigns | last post by:
Hello everyone.. a newbie programmer here wants to ask why is my codes for deleting rows from my databse won't work.... seems that this codes spread to the net and no one refuse to correct it... can someone correct this... #------- <!-- Editable Area --> <?php include ("../dbconnection/connect.php");
0
9607
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10138
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9214
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7674
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5700
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4353
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3879
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.