this my code user want click the edit it will go edit page and delete page.now i want delete the record the same this not going to delete.php. thank you

<?php

$jtitle=$_REQUEST;
$desc=$_REQUEST;

$hostname="localhost";
$username="cds";
$password="cds";
$dbid="cdsemplo_job";
$link=mysql_connect($hostname,$username,$password);
mysql_select_db($dbid) or die("not connected");


$result=mysql_query("select * from job");

echo "<table border='1'>

<th>Jobtitle</th>
<th>JobDesc</th>
</tr>";

while($row=mysql_fetch_array($result))
{

echo " <tr> ";
echo "<td>" . $row . "</td>";
echo "<td>" . $row . "</td>";
echo "<td align='right'><a href='edit.php?jtitle='.$jtitle>Edit/&nbsp;</a>&nbsp;<a href='delete.php?jtitle=$jtitle'>Delete&nbsp;</a></td>";

echo "</tr>";
}

echo "</table>";

mysql_close($link);

?>

I don't understand what you mean by your title.. :) Can you be more specific ?

i am beginner of the php..
this file index.php
if i click delete link go to delete page and delete the selected record. but i want delete the record in index.php page don't go delete.php any query...

Write what you have in delete.php in index.php under certain condition. I am sure you are passing some value to delete.php to delete the record. For example, <a href="delete.php?id=$xyz">delete</a> You can check in index.php if $_REQUEST is set.
ie., in index.php

if(isset($_REQUEST['id']) && !empty($_REQUEST['id'])) {
  //execute the query to delete the record for this particular id
}

this code error is coming

<html>
<head>
</head>
<body align="center" left="20px" right="20px" bgcolor="#fffff">
<?php

$jtitle=$_REQUEST;
$desc=$_REQUEST;

$hostname="localhost";
$username="cds";
$password="cds";
$dbid="cdsemplo_job";
$link=mysql_connect($hostname,$username,$password);
mysql_select_db($dbid) or die("not connected");


$result=mysql_query("select * from job");

echo "<table border='1'>

<th>Jobtitle</th>
<th>JobDesc</th>
</tr>";

while($row=mysql_fetch_array($result))
{

echo " <tr> ";
echo "<td>" . $row . "</td>";
echo "<td>" . $row . "</td>";
echo "<td align='right'><a href='edit.php?jtitle='.$jtitle>Edit/&nbsp;</a>&nbsp;
<a href='index.php?jtitle=$jtitle'>Delete&nbsp;</a></td>";

echo "</tr>";
}

echo "</table>";

mysql_close($link);

?>
</body>
</html>


<?php
$jtitle=$_GET;
echo $jtitle;


$hostname="localhost";
$username="cds";
$password="cds";
$dbid="cdsemplo_job";
$link=mysql_connect($hostname,$username,$password);
mysql_select_db($dbid) or die("not connected");

mysql_query("delete from job where jobtite=$jtitle") or die("error");
echo "one row delete";
mysql_close($link);
?>

mysql_query("delete from job where jobtite='$jtitle'") or die("error");

Edited 3 Years Ago by Reverend Jim: Fixed formatting

thank you nav33n , your wonder full replay. i got solution

below th e code


<html>
<head>
</head>
<body align="center" left="20px" right="20px" bgcolor="#fffff">


<?php

$jtitle1=$_GET;


$hostname="localhost";
$username="cds";
$password="cds";
$dbid="cdsemplo_job";
$link=mysql_connect($hostname,$username,$password);
mysql_select_db($dbid) or die("not connected");
$res=mysql_query("delete from job where jobtite='$jtitle1'");


$result=mysql_query("select * from job");
echo "<table border='1'>
<th>Jobtitle</th>
<th>JobDesc</th>
</tr>";

while($row=mysql_fetch_array($result))
{
$jtitle=$row ;

echo " <tr> ";
echo "<td>" . $row . "</td>";
echo "<td>" . $row . "</td>";
echo "<td align='right'><a href='edit.php?jtitle=$jtitle'>Edit/&nbsp;</a>&nbsp;
<a href='index.php?jtitle1=$jtitle'>Delete&nbsp;</a></td>";

echo "</tr>";
}

echo "</table>";

mysql_close($link);

?>
</body>
</html>

This article has been dead for over six months. Start a new discussion instead.