PHP Arrays and mysqli multi query -
i'm trying understand 2 things:
- if following possible;
- what doing wrong implementing it.
i have array in php manually coded:
$q[1] = 'monday'; $q[2] = 'tuesaday'; $q[3] = 'wednesday';
i have seperate mysqli multi-query
bringing set of data. iterate though multi query , echo results, need include information within manually coded php array, detailed above - current code follows:
echo "<tr><td class='qnum'><span class='bold'>". $n .".</span></td> <td width='450px' > ". $q[$n] ." (<span class='italics'>". $row[0] ."</span>)</td> <td class='set2'>".$row[9]."%</td>";
i have pointer $n
increases mysqli query loops through results , i'm using $q[$n]
try , pull in relevant data php query doesn't work. however, odd is change $q[1] = 'monday';
$q = 'monday';
, reference $q
in echo statement - works!!!
i've included mysqli code reference below:
if ($mysqli->multi_query($query)) { $n = 0; { if ($result = $mysqli->store_result()) { $i = 1; $p = 1; while ($row = $result->fetch_row()) { $n++; echo "<tr><td class='qnum'><span class='bold'>". $n .".</span></td> <td width='450px' > ". $q[$n] ." (<span class='italics'>". $row[0] ."</span>)</td> <td class='set2'>".$row[9]."%</td>"; echo "</tr>"; $result->free(); } } while ($mysqli->next_result()); } $mysqli->close();
any thoughts, ideas, suggestions on going wrong?
looks do-while loop bit odd... shouldn't syntax do { ... } while(condition);
seem using mixture of two.
also, $q
has 3 elements... if you're sure want use $n
increments in loop, maybe use modulo there's $q
index $n
?
example: $q[$n % count($q)]
i'm fishing here because i'm not entirely sure what's aiming at.
Comments
Post a Comment