php - Passing Array through Post and Pulling data from db -
so i'm passing along information previous form via post array. when attempt pull information database, not finding records. yet data dump showing array "pre_fodder" has values. array 'item' coming empty. =(
html
<div> stuff here <br /> <input type="checkbox" name="pre_fodder[]" value="<? item[item_id} ?>" /> </div> <div> stuff here <br /> <input type="checkbox" name="pre_fodder[]" value="<? item[item_id} ?>" /> </div> <div> stuff here <br /> <input type="checkbox" name="pre_fodder[]" value="<? item[item_id} ?>" /> </div>
php
$i = 0; $a = count($_post['pre_fodder']); while ( $i < $a ) { print_r ($_post[pre_fodder][$i]); $_post[pre_fodder][$i] += 0; print_r ($_post[pre_fodder][$i]); $data = "select * items inventory_id='$_post[pre_fodder][$i]'"; $result = mysqli_query($data); $item = mysqli_fetch_assoc($result); print_r($item); $i++; }
you don't have loop, can in single query using in
clause
$sql = "select * items inventory_id in ('" . implode("','", $_post['pre_fodder']) ."')"; $rs = mysql_query($sql); while ($r = mysql_fetch_assoc($rs)) { print_r($r); }
Comments
Post a Comment