Jump to content

Select first letter


Arbitus

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.