Jump to content

Recommended Posts

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:

$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. I'm guessing I'm using arrays wrong (It has been a long, long time), but it's driving me crazy! Thoughts? Also, thanks a ton for the help!

$row[$po_num] references a non-existant variable $po_num. You probably meant the index named 'po_num'.

 

You should be using quotes (single-quotes whenever possible) around array index names and you should also be developing and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON in your php.ini to get php to help you with mistakes like this one. There would have been an error concerning an undefined variable $po_num or an undefined index for $row.

$row[$po_num] references a non-existant variable $po_num. You probably meant the index named 'po_num'.

 

You should be using quotes (single-quotes whenever possible) around array index names and you should also be developing and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON in your php.ini to get php to help you with mistakes like this one. There would have been an error concerning an undefined variable $po_num or an undefined index for $row.

 

Mind=Blown. I'm getting there. Thank you :)

see if this does the trick

 

<?php
$queryall = "SELECT `po_num`
   FROM `new_batch`
   WHERE `isStatus` = 1";
$result = mysql_query($queryall) or die(mysql_error());
while($row=mysql_fetch_array($result)) {
   $unack[] = $row['po_num'];
}
foreach($unack as $k => $v) {
   echo "$k: $v<br />";
}

 

UPDATE::

 

I didn't see PFMaBiSmAd's post.

 

If you want to figure this out yourself (which I strongly suggest) ignore my post ;)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.