PHP - Moved: A Href Question
This topic has been moved to HTML Help.
http://www.phpfreaks.com/forums/index.php?topic=317591.0 Similar TutorialsThis topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=308673.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=329124.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=315388.0 Hi guys; I've managed to find my way into something of a maze. <td> <a href="'Details/21/index.php'"?id= . $id .'>" . $row['id'] . "</a> </td> I'm looking at this line in the code. I realise it's currently in the wrong syntax but I'm just trying multiple different variations. At the moment I'm actually just trying to make it go to a static link but my real goal is to - get it to pick up the id number, of the id row I click, and concatenate that with the rest of my address string. Then use that as the href. Something like this: - "'Details/' + $id + '/index.php'" It's really confusing me though inside this loop and for some reason the id number is being picked up as an int, by the looks of things. It's getting above my level of understanding. Any chance one of you masters would through a n00b a lifeline?
This is my code below
<!DOCTYPE html> <html> <head> <title>LifeSaver DB</title> <h1> LifeSaver Database </h1> </head> <body> <table> <tr> <th>Id</th> <th>Location</th> <th>Initials</th> <th>TimeStamp</th> <th>Notes</th> </tr> <?php $conn = mysqli_connect("localhost", "meh", "pas", "DB"); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT * FROM LifeSaver1 ORDER BY id DESC"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { //for href row $id = $row['id']; $Footage = ['Footage']; echo "<tr> <td> <a href="'Details/21/index.php'"?id= . $id .'>" . $row['id'] . "</a> </td> <td>" . $row["Location"] . "</td> <td>" . $row["Initials"]. "</td> <td>" . $row["TimeStamp"]. "</td> <td>" . $row["Notes"] . "</td> </tr>";} //show table echo "</table>"; } else { echo "0 results"; } $conn->close(); ?> </table> </body> <style> table, td, th { border: 1px solid black; margin: auto; } table { border-collapse: collapse; color: #000; <!--font colour --> font-family: monospace; font-size: 18px; text-align: center;} th { background-color: #337AFF; color: white; font-weight: bold; } tr:nth-child(odd) {background-color: #add8e6} </style> </html> Edited February 8, 2020 by JonnyDriller This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=342468.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=345714.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=310658.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=321915.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=342707.0 This topic has been moved to Other Web Server Software. http://www.phpfreaks.com/forums/index.php?topic=330622.0 This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=317879.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=315227.0 This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=353404.0 Amazingly, threads about application design belong in the Application Design sub-forum. This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=358384.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=305964.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=321972.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=307000.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=354997.0 This topic has been moved to Application Frameworks. http://www.phpfreaks.com/forums/index.php?topic=357345.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=357263.0 |