Jump to content

Article help


steve24

Recommended Posts

Hi im new to php however i have made a site where i have lots of animals on so instead of having a different html page for each animal i decided to put a form on there and add animals using a form and some php. I have done this and it adds and lists them in links. To list them in links i have done

 

  <?php
      include ("connect.php");
$query ="SELECT * FROM weblog ORDER BY entrydate DESC LIMIT 10";

       $result= mysql_query($query, $connection); 

      while ($a_row = mysql_fetch_assoc($result)) { 
          print "<p><a href='".$a_row['entrytitle'] ."'>".$a_row['entrytitle'] ."</a></p>";  
        }
        ?>

So far when i click a link its page was not found, id like to know how i can click it so it gets the data from that spacific animal from the database.

 

any help would be great  :D

 

Link to comment
https://forums.phpfreaks.com/topic/202663-article-help/
Share on other sites

You could have something like:

 

animals.php?animal=XX

 

<?php
$animal = mysql_real_escape_string($_GET['animal']);

$sql = "SELECT * FROM `table` WHERE `animal`='".$animal."'";
$res = mysql_query($sql) or die(mysql_error());

// check if animal exists
$row = mysql_fetch_assoc($res);
?>

Link to comment
https://forums.phpfreaks.com/topic/202663-article-help/#findComment-1062287
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.