<?php
include "ludigidb.php";
session_start();
if ( !isset( $_SESSION['user'] ) && $_SESSION['user'] == "") {
header("location:admin.php");
}
$db = new luDigi_db ();
$jk = $db->do_some_magic($db->run_q("select * from emc_leadgen order by emc_time_date desc" ));
$g=count($jk);
$colnames =array();
if (count($jk) > 0) {
foreach($jk[0] as $k=>$v)
$colnames[] = $k;
}?>
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel">
<html>
<head>
WELCOME <?=$_SESSION['user']?></br>
<a href="logout.php" >log-out</a></br>
<title> emc promo 1</title>
<meta http-equiv="Content-type" content="text/html;charset=utf-8" />
</head>
<body>
<b>the total no rows are :</b><?=$g?>
<table cellpadding="5" border="1" style="width:450px;"><tr>
<?php for ($i=0; $i < count($colnames); $i++) { ?>
<td><?=$colnames[$i]?></td>
<?php }?>
<td>DELETE</td>
<td>EDIT</td>
</tr>
<?php for ($i=0; $i < count($jk); $i++) { ?>
<tr>
<?php for ($ii=0; $ii < count($colnames); $ii++) {?>
<td><?=$jk[$i][$colnames[$ii]]?></td>
<?php }?>
<td><form action="del.php" method="POST">
<input type='hidden' name='id' value= <?php echo $jk[$i];?>>
<input type="submit" name="downld" value="DELETE" >
</form></td>
<td><form action="edit.php" method="POST">
<input type="hidden" name="id1" value="<?=$jk['$i'];?>">
<input type="submit" name="downld" value="UPDATE " >
</form></td>
</tr>
<?php } ?>
</table>
</body>
</html>
As you can see in my program, I'm making a table where all the column names and their respective values are coming. I have also made a delete and edit button. In delete or edit button I'm passing a hidden value, ie $jk[$i]
.
I solve my problem, now I am passing all the column values to check by this I am able to delete and update user details very easily.