Jump to content

Recommended Posts

 

 

Ok,

 

 

I have the following code below. $piod is an array containing elements and the if statement is supposed to act depending on the elements in the array. The problem is it dosen't loop. When i echo $piod[$j] nothing gets outputted.

 

sample of $piod=array ('praden','draden')

 


          if ($_SESSION['perform'] == 1) {      
       for ($j = 0; $j <2; $j++) {
       if ($parameterselect == $piod[$j]) {  
                 
           # first column
    echo '<td';
    echo ' bgcolor="#ffffee" class="a10_b"><nobr> <b>';
    echo  $nval[$j];
    echo '</b> </nobr>';
    echo '</td>';
    echo  $piod[$j];
    echo "<td><nobr> <input name=name".$counterup." type=hidden size=8 value=$nval[$j]> </nobr></td>"; 
    echo "<td class=a10_b><input name=test_value".$counterup." type=text size=8 value=$pval[$j]> </td>";
    echo "<td><nobr> <input name=msr_unit".$counterup." type=hidden size=7 value=$ms_r[$j]> </nobr></td>";
    echo "<td><nobr> <input name=ranges".$counterup." type=hidden size=7 value= $rval[$j]> </nobr></td>";             
   
        $counterup++;


     
       }

 

Link to comment
https://forums.phpfreaks.com/topic/55081-learning-arrays/#findComment-272969
Share on other sites

hi,

 

Please check this

 

In the above code  (if ($parameterselect == $piod[$j]) {  ) is wrong,

Before the if loop select the variable $parameterselect then only the loop will execute.

 

<?

$parameterselect='draden';

$piod=array ('praden','draden');

 

//if ($_SESSION['perform'] == 1) {     

      for ($j = 0; $j <2; $j++) {

      if ($parameterselect == $piod[$j]) { 

               

          # first column

    echo '<td';

    echo ' bgcolor="#ffffee" class="a10_b"><nobr> <b>';

    echo  $nval[$j];

    echo '</b> </nobr>';

    echo '</td>';

    echo  $piod[$j];

    echo "<td><nobr> <input name=name".$counterup." type=hidden size=8 value=$nval[$j]> </nobr></td>";

    echo "<td class=a10_b><input name=test_value".$counterup." type=text size=8 value=$pval[$j]> </td>";

    echo "<td><nobr> <input name=msr_unit".$counterup." type=hidden size=7 value=$ms_r[$j]> </nobr></td>";

    echo "<td><nobr> <input name=ranges".$counterup." type=hidden size=7 value= $rval[$j]> </nobr></td>";           

 

        $counterup++;

 

 

  }}

    //  }

 

R u able to understand this?

Link to comment
https://forums.phpfreaks.com/topic/55081-learning-arrays/#findComment-272971
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.