Reputation: 644
I should get id
from a table to make a request. But I did it in this way.
My table : id(AI);name(Varchar);authir(varchar);category(varchar);
I think if there any solutions to make that thank you my problem appears in this lines:
Print "<td><a href='editt.php?id=$id'>edit</a> </td>";
Print "<td> <a href='delete.php?id=$id'>delete</a> </td>";
Full code:
<table class="table table-hover">
<thead>
<tr>
<th>Book name</th>
<th>Author</th>
<th>Category</th>
<th><th>
<th><th>
</tr>
</thead>
<tbody>
<?php
$id = 0;
while($info = mysql_fetch_array($data)) {
$id++;
Print "<tr>";
Print" <td>".$info['name']."</td>";
Print "<td>".$info['author']."</td>";
Print "<td>".$info['category']."</td>";
Print "<td> <a href='editt.php?id=$id'>edit</a> </td>";
Print "<td> <a href='delete.php?id=$id'>delete</a> </td>";
Print " </tr>";
}
?>
I wondered if there are some other ways to make redirect with current id of selected row id=$id Can you look photo there if pointer in edit or delete link link id is =2 but actually in db it is 3
Upvotes: 3
Views: 6896
Reputation: 17289
if you can show the table structure and full php code we can help more, but just for now it seems you should just:
while($info = mysql_fetch_array($data)) {
Print "<tr>";
Print" <td>".$info['name']."</td>";
Print "<td>".$info['author']."</td>";
Print "<td>".$info['category']."</td>";
Print "<td> <a href='editt.php?id=".$info['id']."'>edit</a> </td>";
Print "<td> <a href='delete.php?id=".$info['id']."'>delete</a> </td>";
Print " </tr>";
}
And stop using mysql_*
functions, It is deprecated. You should use mysqli or PDO.
Upvotes: 3