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;
Lets create a table for that database
Code:
USE muu;
CREATE TABLE info(id INT NOT NULL AUTO_INCREMENT, name VARCHAR(80), title VARCHAR(80), PRIMARY KEY(id));
Now lets set auto increments value to 1111 so you don't have to manually enter it.
Code:
ALTER TABLE info AUTO_INCREMENT=1111;
Lets add some default data
Code:
INSERT INTO info (name,title) VALUES ("pein","Kami");
INSERT INTO info (name,title) VALUES ("konan","Tenshi");
INSERT INTO info (name,title) VALUES ("amaterasu","Megami");
INSERT INTO info (name,title) VALUES ("izanumo","Megami");
INSERT INTO info (name,title) VALUES ("izanagi","Kami");
INSERT INTO info (name,title) VALUES ("sakura","Tenshi");
You will need to change the database password and username on both files before you start.
Multi.php
PHP Code:
<?php
$host = "localhost";
$user = "pein87";
$pass = "daking";
$con = 0;
$dbs = 0;
$re = 0;
$se = 0;
$C = mysql_connect($host,$user,$pass);
if($C)
{
$con = 1;
}
$D = mysql_select_db("muu",$C);
if($D)
{
$dbs = 1;
}
$Q = mysql_query("SELECT * FROM info");
if($Q)
{
$re = 1;
}
if(mysql_num_rows($Q) > 0)
{
$se = 1;
}
if($con == 1 && $dbs == 1 && $re == 1 && $se == 1)
{
echo "<form method=\"post\" action=\"p.php\">";
while(($dat = mysql_fetch_assoc($Q)) !== false)
{
echo "<input type=\"checkbox\" name=\"id[]\" value=\"$dat[id]\" />" . $dat['name'] . ": " . $dat['title'] . "<br />";
}
echo "<input type=\"submit\" value=\"delete\" />";
echo "</form>";
}
?>
multi.php gets the data from the database and displays that data as checkboxes with each name and title being displayed to the side. The value of the input elements is the id of each row. Because each one is unique they serve as an excellent way to delete them. Take note that the name I used for each checkbox tag is id[]. Each checkbox value attribute is set to the value of $dat['id'], which is the id of each row from the database.
p.php
PHP Code:
<?php
$uv = $_POST['id'];
$cs = 0;
$host = "localhost";
$user = "pein87";
$pass = "daking";
$con = 0;
$dbs = 0;
$ct = 0;
$ac = 0;
$C = mysql_connect($host,$user,$pass);
if($C)
{
$con = 1;
}
$D = mysql_select_db("muu",$C);
if($D)
{
$dbs = 1;
}
if($uv)
{
$cs = 1;
}
if($cs == 1)
{
if(is_array($uv))
{
$ac = count($uv);
if($con == 1 && $dbs == 1)
{
foreach($uv as $k)
{
$Q = mysql_query("DELETE FROM info WHERE id = '".$k."'");
if($Q)
{
$ct++;
}
}
echo "You sent " . $ac . " items to be deleted. " . $ct . " items where deleted!";
}
else
{
echo "not connected to server and no database selected";
}
}
else
{
echo "not an array";
}
}
?>
p.php processes the data being sent by the multi.php file. It does all the work and uses flags instead of output data to tell if something is set or not.
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:
$b = "Kami";
$Q = mysql_query("SELECT * FROM info WHERE title = '".$b."'");
its
As far as adding the data I've never seen a multi insert before so I can't help you there but you'd use this in your query
Code:
INSERT INTO table_name (column_name_1,column_name_2) VALUES ("value_1","value_2")
good luck with your work.