Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Php Pagination With Letters?, A,B,C...
alex1985
post Mar 10 2008, 05:56 PM
Post #1


Super Member
*********

Group: [HOSTED]
Posts: 397
Joined: 9-February 08
Member No.: 57,615



How do people make categories like the ones on the musical portals that look like ABC. The user just click the letter and then he got the list of available songs for this artists, if you know, please, let me know as well.
Go to the top of the page
 
+Quote Post
galexcd
post Mar 10 2008, 06:26 PM
Post #2


Define:EVIL PROGRAMMER (ē'vəl prō'grăm'ər)- n. An organism that converts caffeine into evil software.
***********

Group: [HOSTED]
Posts: 1,074
Joined: 25-September 05
From: Los Angeles, California
Member No.: 12,251



Well if you are using sql to store all of these results, you can find all of those that start with a certain letter with this sql code:
SQL
SELECT * FROM [tablename] WHERE [fieldname] LIKE '[letter]%'


So your php code would look something like this:
CODE
$result=mysql_query("SELECT * FROM songs WHERE name LIKE '".$_GET['letter']."%'");
for($i=0;$i<mysql_num_rows($result);$i++)echo mysql_result($result,$i,"name");
Go to the top of the page
 
+Quote Post
alex1985
post Mar 11 2008, 10:55 AM
Post #3


Super Member
*********

Group: [HOSTED]
Posts: 397
Joined: 9-February 08
Member No.: 57,615



So, you mean in the table itself, I need create kind of alphabet (A-Z), then create PHP Code as well as Query, to show the songs I got from that letter.
Go to the top of the page
 
+Quote Post
truefusion
post Mar 11 2008, 01:31 PM
Post #4


Ephesians 6:10-17
Group Icon

Group: [MODERATOR]
Posts: 1,917
Joined: 22-June 05
From: The World of Gentoo
Member No.: 8,528



QUOTE(alex1985 @ Mar 11 2008, 06:55 AM) *
So, you mean in the table itself, I need create kind of alphabet (A-Z), then create PHP Code as well as Query, to show the songs I got from that letter.

Basically you should have a table named "artists," with at least three columns (to keep it simple): id, name, songs. We'll assume you know how to make a MySQL database, table, etc. The code provided by alex7h3pr0gr4m3r just searches the table column "name" for the specified syntax in that table. alex7h3pr0gr4m3r's code assumes that you would use the GET method for the pagination (which is common for things like this). In the page where you want the names that the MySQL query picked up, place that code in.
Go to the top of the page
 
+Quote Post
alex1985
post Mar 11 2008, 02:27 PM
Post #5


Super Member
*********

Group: [HOSTED]
Posts: 397
Joined: 9-February 08
Member No.: 57,615



Thanks, it's clear! I got it.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Pagination(8)


 



- Lo-Fi Version Time is now: 11th October 2008 - 08:35 PM