Note that there are some explanatory texts on larger screens.

plurals
  1. POadd to an integer variable after comparing two arrays
    primarykey
    data
    text
    <p>I am fairly new to php. I am trying to update the score everytime I loop over this array. my code only works if the first value of the listbox was selected by the user and it gives a zero if its not selected. please help. This is A.php</p> <pre><code>{ $SkillsArray = array(); $Score=0; $SkillsArray = $_POST['DutiesDesc']; //foreach($SkillsArray as $key =&gt;$value ) { $Sentence = $SkillsArray[0]." ".$SkillsArray[1]." ".$SkillsArray[2]." ".$SkillsArray[3]." ".$SkillsArray[4]." ".$SkillsArray[5]." ".$SkillsArray[6]." ".$SkillsArray[7 ]." ".$SkillsArray[8]." ".$SkillsArray[9]." ".$SkillsArray[10]; } //Get the applicants score for($i=0;$i&lt;11;$i++) { if ($SkillsArray[$i] == $Text[$i]) { $Score = $Score+$Val[$i]; } } } //**** The following is the HTML part of the code(form) &lt;form action = "A.php" method ="POST" enctype="multipart/form-data"&gt; &lt;label for="Position"&gt;Position:&lt;/label&gt;&lt;input type="type" name="Position" size="35" /&gt;&lt;br /&gt; &lt;/p&gt; &lt;p&gt; &lt;!-- &lt;label for="DutiesDesc"&gt;Duties Description:&amp;nbsp;&lt;/label&gt;&lt;textarea name="DutiesDesc" cols="30" rows="5" /&gt;&lt;/textarea&gt;--&gt; &lt;br /&gt; Job Description &lt;select name="DutiesDesc[]" size=5 multiple="multiple"&gt; &lt;option value="&lt;?php echo $Arow['TextF1']?&gt;"&gt;&lt;?php echo $Arow['TextF1']?&gt;&lt;/option&gt; &lt;option value="&lt;?php echo $Arow['TextF2']?&gt;"&gt;&lt;?php echo $Arow['TextF2']?&gt;&lt;/option&gt; &lt;option value="&lt;?php echo $Arow['TextF3']?&gt;"&gt;&lt;?php echo $Arow['TextF3']?&gt;&lt;/option&gt; &lt;option value="&lt;?php echo $Arow['TextF4']?&gt;"&gt;&lt;?php echo $Arow['TextF4']?&gt;&lt;/option&gt; &lt;option value="&lt;?php echo $Arow['TextF5']?&gt;"&gt;&lt;?php echo $Arow['TextF5']?&gt;&lt;/option&gt; &lt;option value="&lt;?php echo $Arow['TextF6']?&gt;"&gt;&lt;?php echo $Arow['TextF6']?&gt;&lt;/option&gt; &lt;option value="&lt;?php echo $Arow['TextF7']?&gt;"&gt;&lt;?php echo $Arow['TextF7']?&gt;&lt;/option&gt; &lt;option value="&lt;?php echo $Arow['TextF8']?&gt;"&gt;&lt;?php echo $Arow['TextF8']?&gt;&lt;/option&gt; &lt;option value="&lt;?php echo $Arow['TextF9']?&gt;"&gt;&lt;?php echo $Arow['TextF9']?&gt;&lt;/option&gt; &lt;option value="&lt;?php echo $Arow['TextF10']?&gt;"&gt;&lt;?php echo $Arow['TextF10']?&gt;&lt;/option&gt; &lt;option value="&lt;?php echo $Arow['TextF11']?&gt;"&gt;&lt;?php echo $Arow['TextF11']?&gt;&lt;/option&gt; &lt;/select&gt;&lt;br /&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload