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
$host = "localhost";
$user = "root";
$pass = "";
$con = 0;
$dbs = 0;
$re = 0;
$se = 0;
$C = mysql_connect($host,$user,$pass);
if($C)
{
$con = 1;
}
$D = mysql_select_db("test",$C);
if($D)
{
$dbs = 1;
}
$Q = mysql_query("SELECT * FROM emp");
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['empno'] . ": " . $dat['empname'] . ": " .$dat['desig'] "<br />";
}
echo "<input type=\"submit\" value=\"delete\" />";
echo "</form>";
}
?>
below is the p.php
Code:
<?php
$uv = $_POST['id'];
$cs = 0;
$host = "localhost";
$user = "root";
$pass = "";
$con = 0;
$dbs = 0;
$ct = 0;
$ac = 0;
$C = mysql_connect($host,$user,$pass);
if($C)
{
$con = 1;
}
$D = mysql_select_db("test",$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 emp 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";
}
}
?>
i need to insert using php code only so that it gets updated in database.
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...