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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.