Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set('display_errors',1);
- error_reporting(E_ALL);
- mysql_connect('localhost', 'root', '');
- mysql_select_db('testdb');
- $result = mysql_query('select * from products');
- $numrows = mysql_numrows($result);
- //****************************************************************
- print "<table border = 3 style = width:400px>";
- for($i = 0; $i < $numrows; $i++)
- {
- $row = mysql_fetch_row($result);
- print "<tr>";
- foreach($row as $cell)
- {
- print "<td>";
- print $cell;
- print "</td>";
- }
- print "</tr>";
- }
- print "</table>";
- mysql_close();
- ?>
- for($i = 0; $i < $numrows; $i++)
- {
- $row = mysql_fetch_row($result);
- print "<tr>";
- foreach($row as $cell)
- {
- print "<td>";
- print $cell;
- print "</td>";
- print "<td>";
- print "DELETE";
- print "</td>";
- }
- print "</tr>";
- }
- $result = mysql_query('select * from products');
- print "<table>";
- while ($row = mysql_fetch_assoc($result)) {
- print "<tr><td>" . $row["name"] . "</td><td>" . $row["surname"] . "</td><td><a href="delete.php?id=<?php echo $row['id']; ?>">Delete</a></td></tr>";
- }
- print "</table>";
- $id = $_GET["id"];
- // Delete sql here. Do not forget to validate id here.
- header("Location: index.php"); // I assume, table page is this
- ALTER TABLE `products` ADD COLUMN `id` INT AUTO_INCREMENT UNIQUE FIRST;
- print "<table border = 3 style = width:400px>";
- for($i = 0; $i < $numrows; $i++)
- {
- $row = mysql_fetch_row($result);
- print "<tr>";
- foreach($row as $cell)
- {
- print "<td>";
- print $cell;
- print "</td>";
- }
- print "<td><a href='delete.php?id=".$row["id"] ."' > delete </a> " ;
- print "</tr>";
- }
- $id = $_GET["id"];
- $delete = " DELETE from yourTable where id = ". $id ;
- mysq_query ( $delete ) ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement