mmarif4u Posted July 2, 2008 Share Posted July 2, 2008 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. Quote Link to comment Share on other sites More sharing options...
kathas Posted July 2, 2008 Share Posted July 2, 2008 $row = $db->sql_fetchrow($query) should be $row = $db->sql_fetchrow($result_table2) Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted July 2, 2008 Author Share Posted July 2, 2008 This is for: <?php $sql="select * from user where mobile !='' and sms = 'X'"; $query = $db->sql_query($sql) or die (mysql_error()); while($row = $db->sql_fetchrow($query)) { ?> I used it inside another loop. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.