html - Include a delete and edit button in a for each statement to output rows from a database in php -
trying include delete , edit button in each statement output rows database. code for each works outputs values database can't figure out how incorporate button shows every tuple. awesome! current code looks like:
try { $stmt->execute(); $results = $stmt->fetchall(); if (!$results) { // check have results echo "no trainingcourses found <br />"; } else { //generate table of trainingcourses print "<table>\n"; echo "<th>meeting id</th><th>title</th><th>date</th><th>link</th>\n"; foreach ($results $row) { echo "<tr>"; echo "<td>" . $row["trainingid"] . "</td>"; echo "<td>" . $row["title"] . "</td>"; echo "<td>" . $row["date"] . "</td>"; echo "<td>" . $row["link"] . "</td>"; echo "</tr>\n"; } print "</table>\n"; } } catch (pdoexception $e) { echo "query failed: " . $e->getmessage(); } } catch (pdoexception $e) { //$conn->rollback(); // if raised exception in our transaction block of statements, // roll work performed in transaction exit('<p>unable complete transaction!</p>'.$e->getmessage()); } thanks help!
foreach ($results $row) { echo "<tr>"; echo "<td>" . $row["trainingid"] . "</td>"; echo "<td>" . $row["title"] . "</td>"; echo "<td>" . $row["date"] . "</td>"; echo "<td>" . $row["link"] . "</td>"; echo "<td><a href='linktodelete.php?id=".$row['trainingid']."'>delete</a></td>"; echo "</tr>\n"; } i added link, should give idea of how change button. want make sure add th header row number of columns matches.
Comments
Post a Comment