Welcome Guest, Not a member yet? Register   Sign In
save database loop position
#1

[eluser]Corbee[/eluser]
Hi,

I had this problem:

I have queried two separate tables from the database,
because they are not connected to each other and
they need to be in one html table in every loop.

I've develop a logic, that is, having a while loop inside a foreach,
but the while loop only extracts one data and save position, then on the next
loop of the foreach, the while loop extracts another data.

This is the pseudo code:

controller
Code:
$data['data1']=$this->MData->getdata1();
$data['data2']=$this->MData->getdata2();

view
Code:
<?php foreach ($data1 as $key=>$list) {?>

<table>
...
data1 item1: &lt;?php echo $list['item1']?&gt;
data1 item2: &lt;?php echo $list['item1']?&gt;
&lt;?php //while loop
switch = 'on';
do
{
//not sure about the code
$specialitem = mysql_fetch_array($data2['item1'])
echo $special item
//How do I save position to the array?
$position = $position + 1
//off the switch
$switch = off
}
while (switch =='on')


?&gt;
...
</table>

&lt;?php } ?&gt;
#2

[eluser]Corbee[/eluser]
Maybe combination of while and for loop does this better, but what CI function do I use when not using foreach? I got used to the ($data as $key=>$list) thing, that I don't have an idea on how to implement it in for or while loop

Thanks




Theme © iAndrew 2016 - Forum software by © MyBB