vendredi 22 avril 2016

PHP: Best Pratice Method to Hide/Show HTML

I'm a novice with PHP and am still learning. I would like to know what best practice method I should use to hide and show HTML to create dynamic pages.

For example, if I use a while loop to display a table of results from a database query, I then want each row to appear as a link to provide more information:

Using $_GET:

while (row = $mysqli_fetch_assoc($resultset)) {
  echo "<td><a href=\"page.php?id=$id\">Example Text</a></td>";
}
$get = $_GET["id"];
if (!$get) {
    // Display default page content
} else {
    // Display different content if there's a GET request
}

Would this be the best way to display a list of items as links, and then upon clicking one, generate a new page based on the info from that link?

Are there any better ways I should know about?

Thanks in advance guys!

Aucun commentaire:

Enregistrer un commentaire