Create multiple (n) arrays
Posted on
16th Feb 2014 07:03 pm by
admin
Hi there,
I have the following need:
I have 2 arrays (coming from a databases)
Array2 is related to Array1 -
Example:
Array1
Dog, abc
Cat, bcd
Horse, cde
Array2,
meat, abc
bones, abc
fish, bcd
grain, cde
grass, cde
So, I need the array2 split up into separate arrays - but I am will never know in advance how many rows in both arrays there will be.
Basically, I need to display the data so:
Dog
<ul>
<li>meat</li>
<li>bones</li>
</ul>
Cat
<ul>
<li>fish</li>
</ul>
Horse
<ul>
<li>grain</li>
<li>grass</li>
</ul>
As said, the second array will change very often - but will always have the key from the first array
Any help very much appreciated. I do have it sort of working - but EVERY entry from array2 appears under every entry from array1 :-
here is the code that I have so far written:
Code: <?php
$fquestions = $record->getRelatedSet('Markt.FFragen');
$questions = $record->getRelatedSet('FFragen.Fragen');
foreach( $fquestions as $fquestion ) {
$ffrage = $fquestion->getField('Markt.FFragen::fFrage');
$ffgroup = $fquestion->getField('Markt.FFragen::ffgroup');
$ffrageID = $fquestion->getField('Markt.FFragen::ID');
echo'<h3><a href="#">'.$ffrage.'</a></h3>
<div>
<ul>';
foreach( $questions as $question ) {
$frage = $question->getField('FFragen.Fragen::Frage');
$frageID = $question->getField('FFragen.Fragen::ID');
echo '<li>'.$frage.'<div id="slider"></div></li>';
}
echo '</ul>
</div>';
}
?>
Many thanks in advance
No comments posted yet
Your Answer:
Login to answer
274
6
Other forums
How to store checkbox array in a session, and then be able to add to it?
I'm trying to store an array of checkbox values into a session array, sort of like a shopping cart,
defining website tags
Hi,
What would be the best way to define tags for my site, such as website title, url etc.
Multiple while loops
I have several DB queries that I know should be returning results and aren't. I have a feeling it ha
asp authentication problem
Hello all,
I want to use the asp authentication (from asp.net configuration) in my web site. there
login to other site by sending post variables
hey,
here is my problem: my school gave me a mail account for school-stuff use. they mail us
Why is my row count 0?
Here's the MySQL query i'm running. It basically pulls data from 2 tables based on some data passed.
Need help with an email blocker for a guessbook
I am new with php and here is a simple guessbook page but I am being hit with spam from a group of t
mysql UNION | warning mysql_fetch_array !!
Code: <?php
$i = 0;
$query1="SELECT * FROM `products` WHERE `div
Web Host List
Here is a list of web hosts that offer PHP and MySQL. It is no where near a full list, but it is mos
DBCA Templates
Hi all,
I'm working on creating a template for DBCA, but can't find any documentation on the