looping through fields using variables (newbie problem)

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
plu
Forum Newbie
Posts: 1
Joined: Thu Nov 27, 2008 8:58 am

looping through fields using variables (newbie problem)

Post by plu »

had a search around for this particular problem but had no joy, any help would be great.

I'm trying to send some data from MySQL server into flash via PHP.
Problem is the using a variable instead of the exact string in a while loop I think...

==================================================================
here is my code:
<?php

$leilField = $_POST['dataBaseTarget'];
$year = $_POST['yearTarget'];

$connect = mysql_connect("********", "********", "********");
mysql_select_db("********", $connect);


$result = mysql_query("SELECT ID, $leilField FROM booking_dates_2008");

$count=0;
while($row=mysql_fetch_array($result)){

echo "id$count=$row[ID]&date$count=$row[$leilField]&";
$count++;

}
echo "count=$count";

?>

================================================
Any ideas what I'm doing wrong here?
cheers
User avatar
Peter Anselmo
Forum Commoner
Posts: 58
Joined: Wed Feb 27, 2008 7:22 pm

Re: looping through fields using variables (newbie problem)

Post by Peter Anselmo »

What is happening when you run the code? Is there an error message?
Post Reply