![]() |
inserting and deleting in php
hi all,
i have written a code in php for inserting and deleting multiple records using check boxes."test" is the database name. "emp" is the table name which contains the following records in my database. empno empname desig 1111 raju pilot 1112 ram chef 1113 ramu doctor 1114 paul engineer 1115 ajay player now i want to delete one or more records and insert the records in to the above table.. i have written the below code for deleting but the table values are not displaying and i need to delete also using check box. below is delete_multiple2.php Code:
<?phpbut it is not inserting..... below is insert.php Code:
<?phpand deleting any no of times.. kindly tell me how to do it.... where is my code went wrong....... |
Re: inserting and deleting in php
1: please put the code in PHP tags as it would realy help in figuring out bugs :)
okay your problem, what you need is not so clear to me as got the part in which you wanna mark the users with checkboxes and then use a single delete to delete the stuff, but you havent mentioned whether you have failed in this or any other place but i didnt get what you wanna do with insert/delete combined t gether are you trying to make a control panel with add/update/delete function @ one place? |
Re: inserting and deleting in php
I'll help you this is working code I just wrote and tested for you. This is an example of how to get the desired effect your trying to get.
First create a new database, for the example you'll need to use mine Code:
CREATE DATABASE muu;Code:
USE muu;Code:
ALTER TABLE info AUTO_INCREMENT=1111;Code:
INSERT INTO info (name,title) VALUES ("pein","Kami");Multi.php PHP Code:
p.php PHP Code:
I've tested this several times and it works. This is only an example but this should help you understand how to get what you want done. Also when using variables in your sql statements they need to be done like so: PHP Code:
PHP Code:
Code:
INSERT INTO table_name (column_name_1,column_name_2) VALUES ("value_1","value_2") |
Re: inserting and deleting in php
can u check for my database...
not getting executed. i am doing exactly as you told above...... my database name is "test" and my table name is "emp" my emp table contains the following values.... empno empname desig 1111 raju pilot 1112 ram chef 1113 ramu doctor 1114 paul engineer 1115 ajay player below is my multi.php Code:
<?php Code:
<?php it must ask fields in separate box as empno: empname: desig: after clicking the submit button it must updated in the database.... but my multi.php i also not getting deleted kindly tell me how to do it... |
Re: inserting and deleting in php
Try these
multi.php PHP Code:
p.php PHP Code:
|
Re: inserting and deleting in php
i am getting the error as
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in C:\xampp\htdocs\multi.php on line 33 what may be went wrong... |
Re: inserting and deleting in php
Use this one. I couldn't test if it worked because I don't have a database set up like yours but no errors where shown aside from the mysql_num_rows() error being triggered because the value wasn't a resource. Other wise no errors.
PHP Code:
|
| All times are GMT +5.5. The time now is 02:49. |