Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8824211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:33:17+00:00 2026-06-14T06:33:17+00:00

hello i’m going to get array data from for. i have a code but

  • 0

hello i’m going to get array data from for. i have a code but it works not good
in the previous code cs=2

for($k=0;$k<$cs;$k++)
{ 


$SQL = "SELECT duration FROM core_network WHERE location=('".$location_c[$k]."')";
$result = mysql_query($SQL);


$cks="0";
$duration=array();
while ($db_field = mysql_fetch_array($result)) {
$duration_c[$cks]= $db_field['duration']; //*here must save to data
 $cks++;

} 
 }

i have saved this code in the search_l.php

 <?php include("lib/search_l.php"); ?>



  <?php
if($cs!=0){
for($i=0;$i<$cs;$i++)
{ 

?>



 <div id="alarmdisplay">
   <table class width="634" border="0" cellspacing="3" cellpadding="3">
  <tr class="search">
    <td width="256"><?php echo $location_c[$i] ?></td>
    <td width="154" class="247"><?php  echo $duration_c[$i]
?></td>
    <td width="194">&nbsp;</td>
  </tr>
 </table>

in here it must be print 2 duration. but it prints only one others have error Notice: Undefined offset: 1 in how to print it by correct?

when i test it to check correct i noticed that:

$result)) {
$duration_c[$cks]= $db_field['duration'];
 $cks++;

} echo $duration_c[$cks]   //*it prints correct i meant prints 2 test data
}

after that

$result)) {
$duration_c[$cks]= $db_field['duration'];
 $cks++;

}  
}
echo $duration_c[$cks]  //*it prints not correct i meant prints only first test data

how to correct it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:33:18+00:00Added an answer on June 14, 2026 at 6:33 am
    $duration_c=array();//Should be declared outside loop
    
    for($k=0;$k<$cs;$k++)
     { 
      $SQL = "SELECT duration FROM core_network WHERE location=('".$location_c[$k]."')";
      $result = mysql_query($SQL);
      $cks = 0;//String variable
      while ($db_field = mysql_fetch_array($result,MYSQL_ASSOC)) {
                                                        //^---------returns associative array
          $duration_c[$cks]= $db_field['duration'];
          $cks++;
       } 
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I have like this 2 tables class User public int UserId{get;set;} { ....
Hello i have this code var queue = new BlockingCollection<int>(); queue.Add(0); var producers =
Hello i need to gater the data from db(MSSQL) in following way: <div id=slider>
Hello I have the following script in PHP: $correct = array(a, a, a, a);
Hello everyone how can I get two values from different select boxes? I get
Hello we have an SQL server application running over a low bandwith connection. We
Hello The following procedure will have to move all constraints from one table to
Hello guys that is not normal :) !! foo.php <?php if (isset($_POST['data'])) $stringData =
Hello good morning everyone, i have an iphone app which is still in development
Hello I have problem that I'm loosing $_POST['id'] value from select tag after clicking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.