[php & mySQL]switching content on home page

I’ve got a php script on my home page thats pulling the content of the last row in my table and displaying it on the home page. This is working fine, and then I have some navigation down the bottom of the home page which is pulling all the names of the projects from the database also.

I’m new to php with databases and was wondering how I could change the content on this index.php using the links. The site is currently at http://david.flexlab.co.uk/

<?php

$result = mysql_query("SELECT * FROM wp_projects WHERE id = 7") or die("error querying database");
$i = 0;
while($result_ar = mysql_fetch_assoc($result)){
?>
 
<a href="<?php echo $result_ar['lightboxImage']; ?>" rel="lightbox[latestwork]" title="<?php echo $result_ar['name']; ?>"><img src="<?php echo $result_ar['largeImage']; ?>" alt="Latest Project" title="Latest Project" /></a>
                        <p><?php echo $result_ar['name']; ?></p>
                        <div class="details">
                            DATE: <?php echo $result_ar['date']; ?> | CLIENT: <?php echo $result_ar['client']; ?> <br />ROLE: <?php echo $result_ar['role']; ?> | TECH: <?php echo $result_ar['tech']; ?><br /><a href="<?php echo $result_ar['link']; ?>">(view site)</a>
                        </div>
<?php
$i+=1;
}
?>

This is the script pulling the last record from the database. Any tutorials or hints as to what to look up would be greatly appretiated.

Dave