What I want to do should be very straight forward but I can't find any tutorials to help, or, more likely, I don't know the technical term for what I'm trying to achieve.
I'm setting up a site for a craft group and within this I want to show a small profile page for each member, no logins, just a photo, bit of info and a link.
I wanted a members page that shows all members, with a small pic and bio, down the page. This I have no problem with.
What I then wanted to do is to create a page, but not a seperate .php file, for each member, as mentioned earlier, when the small pic is clicked on the members page.
I've seen on sites they have:
www.website.com/members.php - where all members are displayed
then :
www.website.com/member.php?member_name=phpnewbie - where the individual profile is shown.
when a certain member is clicked on.
I guess it would involve including files, I'm not really sure. I just don't want to have to create .php files for each one and I know there is a way around this but cannot, for the life of me, fathom it.
My code for the initial members page would be something along the lines of:
<html>
<head>
the usual
</head>
<body>
<?php $page="members"; ?>
<div id="container">
<div id="header">
<?php include("header.inc"); ?>
</div>
<div id="content">
<div id="contentheader">
Members
</div>
<?php
include("misc.inc");
$cxn = mysql_connect($host, $user, $passwd);
if (!$cxn)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("craftgroup", $cxn);
$query= "SELECT * FROM members";
$result = mysql_query($query,$cxn)
or die ('Could not execute query: ' . mysql_error());
$num=mysql_numrows($result);
mysql_close();
?>
<?
$i=0;
while ($i < $num) {
$membername=mysql_result($result,$i,"membername");
$img=mysql_result($result,$i,"img");
$bio=mysql_result($result,$i,"bio");
$url=mysql_result($result,$i,"url");
?>
<div id="contentitem">
<? echo "<a href=\"$url\"><img height=\"120px\" border=\"0\" width=\"120px\" src=\"$img\"></a>"; ?>
<? echo "<a href=\"$url\">$membername</a> $bio"; ?>
</div>
<? $i++; } ?>
<? include("footer.inc"); ?>
</div>
</body>
</html>
This may be completely the wrong way to start going about it but is how I've done it for sites that then linked to other .php files, not within it's own page.
Many Thanks,
Caroline