Forum Posts and While Loop

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
leebrent
Forum Newbie
Posts: 2
Joined: Mon Jul 21, 2008 12:08 am

Forum Posts and While Loop

Post by leebrent »

Hello,

Can someone shed some light on the following piece of code? No matter what I do the $_POST will not work. I know the posts are making it over the the page. It's like PHP will not put the $serviceName information from the query into the print line...

Code: Select all

include("mysql_connect.php");
$sql = 'SELECT serviceID, serviceName FROM service';
$query = $DB->Query($sql);
while($array = $DB->FetchArray($query)){
        extract($array);
        print $serviceName." Value: ".$_POST['$serviceName']."<BR />\r";        
    }
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Forum Posts and While Loop

Post by Christopher »

Try

Code: Select all

include("mysql_connect.php");
$sql = 'SELECT serviceID, serviceName FROM service';
$query = $DB->Query($sql);
while($row = $DB->FetchArray($query)){
        print $row['serviceName']." Value: ".$_POST[$row['serviceName']]."<BR />\r";        
    }
The problem was '$serviceName'.
(#10850)
leebrent
Forum Newbie
Posts: 2
Joined: Mon Jul 21, 2008 12:08 am

Re: Forum Posts and While Loop

Post by leebrent »

Thanks,

That solved my issue!

--B :D
Post Reply