Arbitus Posted December 5, 2008 Share Posted December 5, 2008 I'm trying to set up one of those cool things that has A-Z (each a link to that letter). I'm having trouble with matching the letter clicked and pulling all games that start with that letter from the database. <?php $letter = $_GET['letter']; $system = $_GET['system']; $sql = "SELECT * FROM OSG_Games WHERE system_id = $system ORDER BY title ASC"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { echo $row['title']; echo "<br>"; } Don't really know what to do after this to make it so the echo'd title matches up with the letter picked. Link to comment https://forums.phpfreaks.com/topic/135713-select-first-letter/ Share on other sites More sharing options...
Brian W Posted December 5, 2008 Share Posted December 5, 2008 well, think this may be what you are looking for... <?php $letter = $_GET['letter']; $system = $_GET['system']; $sql = "SELECT * FROM OSG_Games WHERE system_id = $system AND title LIKE '$letter%' ORDER BY title ASC"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { echo $row['title']; echo "<br>"; } Link to comment https://forums.phpfreaks.com/topic/135713-select-first-letter/#findComment-707097 Share on other sites More sharing options...
Xyphon Posted December 5, 2008 Share Posted December 5, 2008 Do something like this to display letters: echo " <a href='/letterthing.php?letter=A'>A</a> and do that for A-Z Then query $Result1= mysql_query("SELECT * FROM table_name WHERE item_name like '$letter%'"); The item name is lets say you are doing cars and in your data base you have Car_Name thats what I mean by item_name. Then, you echo it so for example cars. while($Rows1= mysql_fetch_array($Result1) { $CarName= $Rows1['Car_Name']; echo "$CarName"<br />"; } Thats basically it. Link to comment https://forums.phpfreaks.com/topic/135713-select-first-letter/#findComment-707108 Share on other sites More sharing options...
Brian W Posted December 5, 2008 Share Posted December 5, 2008 easy letter links <?php $letters = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"; $letters = explode(' ', $letters); foreach($letters as $alpha){ echo '<a href="?letter='.$alpha.'">'.$alpha.'</a> '; } ?> Link to comment https://forums.phpfreaks.com/topic/135713-select-first-letter/#findComment-707114 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.