THE BORE

General => The Superdeep Borehole => Topic started by: GilloD on June 08, 2009, 07:42:45 PM

Title: More Noob PHP Q's: How to intialize an array of unknown size?
Post by: GilloD on June 08, 2009, 07:42:45 PM
Basically, I need an array to capture the PO num of every record that has a Status of "1". I have no idea how many records that is. I tried to do $po_array=array();, but it doesn't seem to work.

Code below. I am dumb. Make me smart! I can't belive I've gotten this far:

Code: [Select]
$queryall="SELECT po_num
   FROM new_batch
   WHERE isStatus = 1";
$result=mysql_query($queryall) or die(mysql_error());
$counter=0;
$unack=array();
while($row=mysql_fetch_array($result)){
$unack[$counter]=$row[$po_num];
echo "Counter: $counter <br/>";
echo "Row: $row[po_num] <br/>";
echo "UnAck: $unack[$counter] <br/>";
$counter++;

UnAck(x) always returns nothing.
Title: Re: More Noob PHP Q's: How to intialize an array of unknown size?
Post by: recursivelyenumerable on June 08, 2009, 08:09:03 PM
is there no $unack.Add() method or anything?

spoiler (click to show/hide)
C# version:
Code: [Select]
var unack = (from row in new_batch where row.isStatus == 1 select row.po_num).ToArray();:smug
[close]
Title: Re: More Noob PHP Q's: How to intialize an array of unknown size?
Post by: GilloD on June 08, 2009, 08:10:59 PM
Solved. Am stoopid $po_num would be the variable po_num is the index.