Tuesday, November 3, 2015

using for a mysqli select statement

could someone please direct me to a simple (basic easy) explanation of how to use hyperlinks in a website to display the results of a select statement



To be precise - I am working on the footer section of my website http://www.mandyevansartist.com
when someone clicks on the words 'coloured pencils' I would like them to be taken to the catagory.php page and be shown an array from the database



I know this is possible because I already have made it work by clicking an image - (there is an area in the http://www.mandyevansartist.com/gallery.php page that says 'click on a picture to see others in that catagory')



I have achieved this by



    <?php
session_start();
include 'header.php';
echo '<h1>CLICK ON AN IMAGE TO SEE OTHERS IN THAT CATAGORY</h1>';
$con = mysqli_connect("*","*","*","*");
$db = mysqli_select_db("images", $con);

$answer = mysqli_query($con,"SELECT image FROM images where HEAD = 'true'");
echo '
';
echo '
    ';
    while ($row = mysqli_fetch_array($answer)) {
    $pic = $row[image];
    $link ="" . ' '. "";
    echo '
  • ' .$link.'
  • ';
    }
    echo '
';
echo '
';
?>


At this point my footer.php is mainly html (enclosed in an echo'') with links going to nowhere



    <!--/footer-one-->


one of the ways I have tried to insert a mysqli query into it



        <h1>GALLERY</h1>';
$answer=mysqli_query($con,"SELECT image FROM images WHERE catagory = pencils");
while ($answer2 = mysqli_fetch_array($answer));
$link = <p><a href = "catagory.php?id=$answer2">family portraits</a></p>
echo '<p>' .$link.'</p>';
echo' <p><a href = "#" >coloured pencils</a></p>


which just comes up with a parse error - unexpected "<"



I am looking for a tutorial to guide me through this process because i have looked and looked and cant find one

No comments:

Post a Comment