Jump to content
MakeWebGames

Loop inside a loop


microsocket
 Share

Recommended Posts

Afternoon, wondering if anyone can help me solve this.

I need to loop inside a loop and create an output from this below...

 

$result = $DBO->query("SELECT * FROM `stocks` ORDER BY `id` ASC");
while($line = $DBO->fetch_array($result, MYSQL_ASSOC)) {
$id = $line['id'];

$resulta = $DBO->query("SELECT * FROM `shares` WHERE `userid`='".$User->id."' AND `companyid`='".$id."'");
while($linea = $DBO->fetch_array($resulta, MYSQL_ASSOC)) {	
$fluc = $linea['cost'];

}
 }  

 

the first part needs to select all the id's from one table

The second part needs to then select a field 'cost' from another table that matches the user id and the stock id (pulled from first table)

if that makes sense.

Anyone care to point me in the right direction please ?

Thanks

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...