Hello, I'm really new (ok, three days) but I'm under a bit of a strain to get this project done. Really really close but cannot get the last piece. I cannot find the exact answer I need via google, etc.
Here's the story.
I've got a database that I'm pulling records from. That works.
I need to loop through each selected record, put it into an array and then output that array to a function.
I can loop.
I can array.
I can output a manually contructed array.
I just cannot get the array to loop through the db records.
Total newbie stuff.
All the help files I found so far say, "Dude! you need to loop through your record set." I know that but cannot seem to pull if off.
Any help at all would be terrific. I have a real need for this to be finished in the somewhat near future.
Here's what I have so far. Everything that is listed below works. (Finer points have been left out)
I just cannot figure out where to put the loop.
//php PDF class is from http://www.ros.co.nz/pdf/
//I'm creating PDF mailing labels from a mysql database
include ('class.label.php');
$labeltype="Av5160";
$label= new Clabel($labeltype);
$user_name = "works";
$password = "works";
$database = "works";
$server = "works";
$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);
$SQL = "SELECT * FROM mailinglist";
$result = mysql_query($SQL) or die(mysql_error());
$row = mysql_fetch_array($result);
$count=1; //to be used for while loop, needed for $key
$info = array(
$count=>array("line1"=>"{$row['FIRST NAME']} {$row['LAST NAME']}",
"line2"=>"{$row['2ND NAME']}",
"line3"=>$row['ADDRESS'],
"line4"=>$row['CITY']),
);
$label->makeLabel($info);
Everything here works so far. I just cannot get how to loop through that array and not get errors when the array gets submitted.
Additional information:
$info is sent to makeLable() function that looks like this
while (list($key, $add_arr)=each($labelInfo)) {
//do various things
}
No matter how I create the loop, this while loop thinks that the $add_arr is the entire looping through the record set. If I echo $key and $add_arr, I get back
1 (then 3 pages of text)
I need
1 array('line1', 'line2', 'line3', 'line4', etc.)
Any help at all would be appreciated.
Thanks