Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Turn PHP into CSS Drop Box

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #204559
    motion2082
    Participant

    This might be one for the PHP forum but probably not.

    I have this PHP script which pulls all the GENREs from my Database


    <div class="list-group"> <!--?php //print_r($genres); foreach ($genres as $genre) { ?--> <a href="<?php echo $genre['href']; ?>" class="list-group-item active"><!--?php echo $genre['name']; ?--></a> <!--?php } ?--> </div>

    Looking to list these as links

    Something like

    <div class="links">
    <ul>
    <li>php result 1</li>
    <li>php result 2</li>
    <li>php result 3</li>
    <li>php result etc</li>
    </ul>
    </div>
    

    Is this a PHP question or a CSS?

    #204560
    Paulie_D
    Member

    It’s a PHP question, so I’ll move it there.

    #204589
    Alen
    Participant

    As @traq mentioned above, show us the data contained within $genres.

    But in general, PHP foreach loop:


    $numbers = array(1,2,3,4,5); foreach( $numbers as $number ) { echo $number; }; /* Result: 12345 */ $associates = array( 'president' => 'Jane Doe', 'assistant' => 'Joe Blow', ); foreach($associates as $role => $name) { echo $name . ', ' . $role . '<br/>'; }; /* Result: Jane Doe, president Joe Blow, assistant */

    You can test your code online using http://viper-7.com/8owHD2

    Hope that helps.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.