Hi everyone,
I have a page where I bring multiple rows from my database, but I would like to add 2 options on the right of each row. This options are: Delete and the other one is Edit. So when I click on delete only that row should be deleted or if I click on edit it should open a page bringing all the information of that registry so the user can make any changes.
Can anyone please help me?
This is my code:
session_start();
if (isset($_SESSION['myusername']))
{
echo "";
} else {
header("location:main_login.php");
exit();
}
require('connectar_bd.php');
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
// Count table rows
$count=mysql_num_rows($result);
<table width="500" border="0" cellspacing="1" cellpadding="0">
<form name="form1" method="post" action="<?PHP $_SERVER['PHP_SELF']?>">
<tr>
<td>
<table width="500" border="0" cellspacing="1" cellpadding="0">
<tr>
<td align="center"><strong>Id</strong></td>
<td align="center"><strong>Title</strong></td>
<td align="center"><strong>Author</strong></td>
<td align="center"><strong>Post</strong></td>
<td align="center"><strong>Schedule</strong></td>
</tr>
while($rows=mysql_fetch_array($result)){
<tr>
<td align="center"><? $id[]=$rows['id']; ?><? echo $rows['id']; ?></td>
<td align="center"><input name="tittle[]" type="text"
id="name" value="<? echo $rows['tittle']; ?>"></td>
<td align="center"><input name="author[]" type="text"
id="lastname" value="<? echo $rows['author']; ?>"></td>
<td align="center"><input name="post[]" type="text"
id="email" value="<? echo $rows['post']; ?>"></td>
<td align="center"><input name="date[]" type="text"
id="email" value="<? echo $rows['date']; ?>"></td>
</tr>
}
<tr>
<td colspan="4" align="center"><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</td>
</tr>
</form>
</table>
if($Submit){
for($i=0;$i<$count;$i++){
$sql1="UPDATE $tbl_name SET tittle='$tittle[$i]', author='$author[$i]', post='$post[$i]'
WHERE id='$id[$i]'";
$result1=mysql_query($sql1);
}
}
if($result1){
header("location:prueba1.php");
}
mysql_close();