简体   繁体   中英

how to categorize tables in php using arrays

Im new to PHP. Im creating songbook.

Question 1 : I want to create tables which consists the list of songs alphabetically. I dont want to create A.php, B.php, C.php for every alphabet. I have no idea how to do that. I know how to create a table with array.

<table>
    <tbody>
    <tr>
    <td><?php echo $song; ?>
    </td>
    <td><a href="publicsearch.php?lyric=<?php echo $song; ?>"><?php echo $lyric["title"]; ?></a>
    </td>
    <td><?php echo $lyric["artist"]; ?>
    </td>
    </tbody>
    </table>

Question 2: I want to create a table which shows the results of the same artist in another table.

////Arrays/////

   /////song 197 -  artist jackson////

"197"         => array(

"title"    => "a song with a id - 197",


"chords"    => " ....",

"artist"    => "jackson ",                        

"tags"    => "unknown "

),


   /////song 210 - with same artist jackson////


"210"         => array(

"title"    => "another song with different id - 210 in other table",


"chords"    => " ....",

"artist"    => "jackson",                        

"tags"    => "unknown "

),

Pls help me out.

Maybe instead of looking into a PHP framework/library you should try to connect to a database like MySql, MS-SQL or PostGresql. A solution based on a static PHP array will not be easily editable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM