If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

PHP script to link an alphabetical list?

OK first thing is that i am new to all this, with that sad i have a working alphabetical search script where one clicks a letter such as "G" and the screen displays a list from my database with all the say 'lastNames' of a column that start with the letter "G".

My problem is that after the list is displayed i would like for them to click on said 'lastName' ie "Goodman" and have it link you to another page such as a profile page where then it displays "Goodman"'s info from the database.

Not sure what PDO extesion is or how to use it every thing im coding is in PHP and mysql using phpmyadmin.
my code is based of this that i found online to use
<?php
$results = "";
$letter = "";
if(isset($_GET['letter']) && strlen($_GET['letter']) == 1){
$letter = preg_replace('#[^a-z]#i', '', $_GET['letter']);
if(strlen($letter) != 1){
echo "ERROR: Hack Attempt, after filtration the variable is empty.";
exit();
}
// Connect to database here now
// SELECT * FROM movies WHERE title LIKE '%$letter'
// Use a while loop to append database results into the $results variable ($results .=)
// Close your database connection here after your while loop closes

Not sure what you mean by 'using phpadmin'. In your script above where you "say" 'connect to database...' you really have to have some php code there to call your db and execute a query. That's the part that I was referring to. And PDO is my choice of MySQL interfaces since eliminating the use of the php MySQL_* functions, due to their deprecation.

Thanks for help finaly got it working but now for some reason i could not get the said profile page to display the requested data
ive looked everywhere for help on it all the code i came across the sql = "select " statment is corect and the echo looks fine so not sure whats going caus i click on say "greenfield" the url shows the ?u=lastname but i get another name from the sql list

so if anyone can help with displaying the proper info from data base i mean so that when i echo out $u i should get 'Absinthe' from the url of http://localhost/Test_Site_1/index.php?u=Absinthe and not an $row['NAME'] of say "#26" which is what shows up on screen

1 - turn on error checking and display errors.
2 - do your own error checking after operations such as your query execution.
3 - are your field names spelled correctly and are they all REALLY in capitals? You retrieve the results of your queries using NAME, yet your query itself specifies 'name'. That can't be right.

// http://path/to/script.php?a -- what the page calling this script should generate for a URL
// 'a' will contain the name of the alcohol you wish to lookup

$booze = $_GET['a'];

include_once("inc/mysql_connect.php");$u = "";
$ing = "";
$proc = "";

// order by ID is not doing anything because of limit 1
// you're only getting 1 result because of limit 1
// better to pass the value to lookup in the URL and use $_GET to find that value
// you probably solved this already -- if so just ignore :-)

- order by ID is not doing anything because of limit 1
- you're only getting 1 result because of limit 1
- better to pass the value to lookup in the URL and use $_GET to find that value
- you probably solved this already -- if so just ignore :-)