okay so I am still having some problems..
here it is;
-- page one calls alphatest plus letter key
<?
foreach(range('a','z') as $alphaKey)
{
echo "<a href=\"alphatest.php?key=$alphaKey\">$alphaKey</a> ";
}
--end page
next page is always blank. url reads:"/php/alphatest.php?key=s"
but the script that I have written doesn't engage, nothing appears actually.
here is the script for alphatest.php ;
<html>
<head>
</head>
<body>
<?
//check for required query string variables
if (!$_POST[alphaKey]) {
header("http://isadore.local/~miriam/php/alphabettest.php");
exit;
} else {
//if form variables are present, start a session
session_start();
}
$db_name ="//db-name_is here";
$table_name ="//table_here";
//connect to server and select database
$connection = blah de blah
$db = blah de blah
//build and issue query
$sql ="SELECT id, first_name, last_name FROM $table_name WHERE last_name LIKE '$_POST[Key]%'";
$result = @($sql,$connection)or die(mysql_error());
if ($alphaKey != ""){
//create list block of results
$contact_list ="<ul>";
while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$first_name = $row['first_name'];
$last_name = $row['last_name'];
$contact_list .= "<li><a href=\"show_contact.php?id=$id\">$last_name,$first_name</a>";
}
$contact_list .="</ul>";
echo "$contact_list";
} else {
echo "<p>sorry there are no artists listed under $alphaKey.</P>";
}
?>
<br>
<p><a href="alphabettest.php">Return to Main Menu</a></p>
</body>
</html>
I guess I am not passing the url properly, any advice on something, I can add remove or change??
oh, and if I put an error in my code,
the browser send me a parse error message. so maybe the script is being read? but not executed so the value isn't being passed. but then I shoudl be re-directed back to the alphabet page???
or could it be, that I need to index the last_name column?
cheers,
mir