<?php
mysql_connect("your.hostaddress.com", "username", "password") or die(mysql_error());
mysql_select_db("Database_Name") or die(mysql_error());
$result = mysql_query("SELECT <column name> FROM <table name>");
$data=array(); // to create an array to store result
while ( $row= mysql_fetch_array( $result ))
{
$data = $row;
}
?>
This query returns multiple lines of result like:
abc
def
ghk
...
...
...
...
...
My question is how can I change the looping structure so that each row from output value is feed to the parser one by one.
Using the code snippet above, only one is feed to the parser. But I want each row to be feed to parser one by one.
I found the solution. It works.
<?php
mysql_connect("your.hostaddress.com", "username", "password") or die(mysql_error());
mysql_select_db("Database_Name") or die(mysql_error());
$result = mysql_query("SELECT <column name> FROM <table name>");
while ( $row= mysql_fetch_array( $result ))
{
echo $row['column name']; // to check does it works fine.
// pass the variable " $row['column name'] " as paramter to parser function it works.
//I have tried it.
}
?>
I was using wrong way to input in a array. The best way is to pass directly variable inside the loop to parser function. Then we wouldn’t need any external array to store the results.