Author Topic: More Noob PHP Q's: How to intialize an array of unknown size?  (Read 564 times)

0 Members and 1 Guest are viewing this topic.

GilloD

  • TAKE THE LIFE OF FRED ASTAIRE. MAKE HIM PAY. TRANSFER HIS FAME TO YOU.
  • Senior Member
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.
wha

recursivelyenumerable

  • you might think that; I couldn't possibly comment
  • Senior Member
Re: More Noob PHP Q's: How to intialize an array of unknown size?
« Reply #1 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]
QED

GilloD

  • TAKE THE LIFE OF FRED ASTAIRE. MAKE HIM PAY. TRANSFER HIS FAME TO YOU.
  • Senior Member
Re: More Noob PHP Q's: How to intialize an array of unknown size?
« Reply #2 on: June 08, 2009, 08:10:59 PM »
Solved. Am stoopid $po_num would be the variable po_num is the index.
wha