Jump to content

Loop in Loop


mmarif4u

Recommended Posts

I am trying to build a sms system.

but a bit stuck in retrieving entries from db.

what i am doing is:

					<?php
$sql="select * from user where mobile !='' and sms = 'X'";
$query = $db->sql_query($sql) or die (mysql_error());
$query_table = "SELECT * FROM p_2_45 where NS != ''";
$result_table = $db->sql_query($query_table);
while($array = $db->sql_fetchrow($result_table)) {
//---- sselect individual piers (depends on coming data on time) cron will run in that resprective time ----------
$query_table2 = "select timeline,ChP1,id,timeline from s_2_45_test WHERE node_id='$array[node_id]' order by timeline desc";  
$result_table2 = $db->sql_query($query_table2);
$array2 = $db->sql_fetchrow($result_table2);
$level = abs($array2['ChP1']);
while($row = $db->sql_fetchrow($query)) {												
$msg4 = 'level 3 '.$array['pier'].$array['NS'].' '.$array2['id']; $font = '#FF0000';					
//echo $msg4;
echo "<br>";
$mobile='';
if(ctype_digit($row['mobile']))//can also use is_numeric function
{
$mobile=($row['mobile']);                            
}
if (!empty($mobile)) 
{
$mobile;
//echo $array2['timeline'];	
//echo $mobile;
echo "Your sms content: ".$msg4." ".$mobile;//
echo "<br>";
//echo $msg4;
}
}
}
?>

The output for this code is:

Your sms content: level 3 P119EN 1 012

Your sms content: level 3 P119EN 1 016

Your sms content: level 3 P119EN 1 019

 

which is correct,but there is also another entry which is P118EN,

which i also want to show in the same output after P119EN like:

 

Your sms content: level 3 P119EN P118EN 1 012

Your sms content: level 3 P119EN P118EN 1 016

Your sms content: level 3 P119EN P118EN 1 019

 

So here i am a bit confused about while,if i echo $msg4 outside the while loop then the result is different.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.