Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] problem with output data from database - probably basic stuff
#1

[eluser]nemanjanq[/eluser]
I have something like this, this is edit page for "people"

Code:
<?php foreach ($query as $row): ?>

//some output here

<?php foreach ($query_organisations as $row): ?>
  <option value="&lt;?=$row->id?&gt;">&lt;?=$row->name?&gt;</option>
&lt;?php endforeach; ?&gt;

&lt;?php endforeach; ?&gt;

This is not working, I get errors after end of inner foreach, this is probably wrong way to do it. How should I do it ?
#2

[eluser]benurv[/eluser]
how does the query look like ?
#3

[eluser]benurv[/eluser]
also the error message would help us helping you...
#4

[eluser]nemanjanq[/eluser]
strange things happens, some vars are:

Quote:Undefined property: stdClass::$street_line_2

and some are from wrong ID, I even didn't load!
#5

[eluser]nemanjanq[/eluser]
if I put it like this

Code:
&lt;?php foreach ($query_organisations as $row): ?&gt;
  <option value="&lt;?=$row->id?&gt;">&lt;?=$row->name?&gt;</option>
&lt;?php endforeach; ?&gt;


&lt;?php foreach ($query as $row): ?&gt;

//some output here

&lt;?php endforeach; ?&gt;

it works perfect, problem is when I have foreach in foreach, but I need to, ...
#6

[eluser]nemanjanq[/eluser]
my bad, this way it works. I had a double as $row, ...

Code:
&lt;?php foreach ($query as $row): ?&gt;

//some output here

&lt;?php foreach ($query_organisations as $organisations): ?&gt;
  <option value="&lt;?=$row->id?&gt;">&lt;?=$row->name?&gt;</option>
&lt;?php endforeach; ?&gt;

&lt;?php endforeach; ?&gt;




Theme © iAndrew 2016 - Forum software by © MyBB