- This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- The forum ‘Back End’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
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?
It’s a PHP question, so I’ll move it there.
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.