Monday, 9 September 2013

Using php array_chunk with mysqli_fetch_array

Using php array_chunk with mysqli_fetch_array

I need to break up an array into chunks, but it's the result of a mysql
query that contains multiple values. It looks like this:
$minQuery = "SELECT typeName, typeID FROM invTypes WHERE groupID = '18'";
$con = mysqli_connect('127.0.0.1', $username, $password, 'sdeodyssey107');
$result = mysqli_query($con,$minQuery);
What I need to do is to be able to break this result up into rows of 3 at
a time. I can't seem to find a way to get array_chunk to work with the
multiple values, and everything I have tried with while loops ends up with
me repeating the same value multiple times per row.
Anyone know a good way to handle this? The line that will be printed looks
like this:
echo '<td align="right">' . $typeName . ': <input type="text" size="25"
name="' . $typeName . '|' . $itemID .
'"';if(isset($_GET["$cleanTypeName|$itemID"])) echo
'value="'.$_GET["$cleanTypeName|$itemID"].'"';echo '></td>';
...so I need to have both values available each time I call the function
that prints those lines....

No comments:

Post a Comment