maliary Posted June 11, 2007 Share Posted June 11, 2007 Hi, Am having a really big problem dealing with arrays. How can I improve on this? All suggestions welcome. Quote Link to comment https://forums.phpfreaks.com/topic/55081-learning-arrays/ Share on other sites More sharing options...
kenrbnsn Posted June 11, 2007 Share Posted June 11, 2007 What type of problems are you having? Without a hint as to the problems, we can't begin to help you. Ken Quote Link to comment https://forums.phpfreaks.com/topic/55081-learning-arrays/#findComment-272265 Share on other sites More sharing options...
maliary Posted June 12, 2007 Author Share Posted June 12, 2007 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++; } Quote Link to comment https://forums.phpfreaks.com/topic/55081-learning-arrays/#findComment-272969 Share on other sites More sharing options...
suma237 Posted June 12, 2007 Share Posted June 12, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/55081-learning-arrays/#findComment-272971 Share on other sites More sharing options...
maliary Posted June 12, 2007 Author Share Posted June 12, 2007 Thanks, I've seen it. What's the best way of looping through $piod in the if statement. Quote Link to comment https://forums.phpfreaks.com/topic/55081-learning-arrays/#findComment-273003 Share on other sites More sharing options...
maliary Posted June 12, 2007 Author Share Posted June 12, 2007 how do I do this? Quote Link to comment https://forums.phpfreaks.com/topic/55081-learning-arrays/#findComment-273105 Share on other sites More sharing options...
maliary Posted June 12, 2007 Author Share Posted June 12, 2007 How would I loop an element being used in the if statement? -- $piod Quote Link to comment https://forums.phpfreaks.com/topic/55081-learning-arrays/#findComment-273156 Share on other sites More sharing options...
maliary Posted June 13, 2007 Author Share Posted June 13, 2007 $bump, So......? Quote Link to comment https://forums.phpfreaks.com/topic/55081-learning-arrays/#findComment-273686 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.