Hi,
I'm a relative newbie to PHP/Mysql so please be patient. I have created a new Mysql database and can retrive the data from it succesfully in a reasonable format:
http://cpfc.org/squad/database/
The above php code retrives all the records from the database and displays them in a set of formatted tables.
Here is the code for that page
code:
<?PHP
// Connection Details
$login="login";
$pass ="password";
$db=mysql_connect("localhost",$login,$pass);
// Select Databse (Squad)
mysql_select_db("squad",$db);
// Select Table (squad_orig2)
$sql="select * from squad_orig2";
// Send SQL call to DB
$result=MySQL_query($sql,$db);
while($myrow=MySQL_fetch_array($result))
{
// Grab Data
$name=$myrow["Name"];
$DOB=$myrow["DOB"];
$PlaceofBirth=$myrow["PlaceofBirth"];
$Nationality=$myrow["Nationality"];
$Height=$myrow["Height"];
$Weight=$myrow["Weight"];
$Fee=$myrow["Fee"];
$Position=$myrow["Position"];
$SquadNo=$myrow["SquadNo"];
$International=$myrow["International"];
$Signed=$myrow["Signed"];
$Clubs=$myrow["Clubs"];
$review1 =$myrow["review1"];
$bbsreview =$myrow["bbsreview"];
// Display our results
echo "
<div align=\"center\">
<center>
<table border=\"1\" width=\"70%\" cellspacing=\"0\" cellpadding=\"2\">
<tr>
<td width=\"50%\"><font face=\"Verdana\" size=\"2\"><B>$name</B>
</font></td>
</center>
<td width=\"50%\">
<p align=\"right\">
<font face=\"Verdana\" size=\"2\"><b>
Squad Number:</b> $SquadNo</font></p>
</td>
</tr>
<center>
<tr>
<td width=\"100%\" colspan=\"2\"><font face=\"Verdana\" size=\"2\"><b>Date of Birth:</b> $DOB
<b>Born:</b> $PlaceofBirth <b> Nationality:</b>
$Nationality </font></td>
</tr>
<tr>
<td width=\"100%\" colspan=\"2\"><font face=\"Verdana\" size=\"2\"><b>Height:</b> $Height
<b> Weight:</b> $Weight </font></td>
</tr>
<tr>
<td width=\"100%\" colspan=\"2\"><font face=\"Verdana\" size=\"2\"><b>Fee:</b> $Fee
<b>Signed:</b> $Signed</font></td>
</tr>
<tr>
<td width=\"100%\" colspan=\"2\"><font face=\"Verdana\" size=\"2\"><b>Position:</b> $Position </font></td>
</tr>
<tr>
<td width=\"100%\" colspan=\"2\"><font face=\"Verdana\" size=\"2\"><b>International Honors:</b> $International</font></td>
</tr>
<tr>
<td width=\"100%\" colspan=\"2\"><font face=\"Verdana\" size=\"2\"><b>Previous Clubs:</b> $Clubs</font></td>
</tr>
<tr>
<td width=\"100%\" colspan=\"2\"><font face=\"Verdana\" size=\"2\"><b>Review:</b> $bbsreview</font></td>
</tr>
<tr>
<td width=\"100%\" colspan=\"2\"><a href=\"$review1\" target=\"_blank\"><font face=\"Verdana\" size=\"2\">Official Profile</font></a></td>
</tr>
</table>
</center>
</div>
<BR>
";
}
?>
Pretty striaght forward stuff:
Now what I want to achieve is PHP code that will create a menu with the first field of each record and link it through to the other fields in the record (including the first)
Heres my Menu sofar
http://cpfc.org/squad/database/menu.php
This just grabs the first field in each recordset and diplays them in a bulleted list. I am struggling to get my head round how each of the menu items can be linked through to the rest of the data in their respective recordsets?
Can anyone point me in the right direction?
Thanks in advance:
Heres my menu code:
<?PHP
// Connection Details
$login="";
$pass ="";
$db=mysql_connect("localhost",$login,$pass);
// Select Databse (Squad)
mysql_select_db("squad",$db);
// Select Table (squad_orig2)
$sql="select * from squad_orig2";
// Send SQL call to DB
$result=MySQL_query($sql,$db);
echo "<ul>";
while($myrow=MySQL_fetch_array($result))
{
// Grab Data
$name=$myrow["Name"];
$DOB=$myrow["DOB"];
$PlaceofBirth=$myrow["PlaceofBirth"];
$Nationality=$myrow["Nationality"];
$Height=$myrow["Height"];
$Weight=$myrow["Weight"];
$Fee=$myrow["Fee"];
$Position=$myrow["Position"];
$SquadNo=$myrow["SquadNo"];
$International=$myrow["International"];
$Signed=$myrow["Signed"];
$Clubs=$myrow["Clubs"];
$review1 =$myrow["review1"];
$bbsreview =$myrow["bbsreview"];
// Display our results
echo "<li>$name</li>";
}
echo "</ul>";
?>