Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help needed with SELECT and CONCAT_WS please

Status
Not open for further replies.

luckyblackcat

Programmer
Aug 15, 2002
19
GB
Hi I have a table with 7 fields I need to SELECT 5 of these fields and output all ROWS into one huge string with fields seperated by .. say '|'


Alternatively

I need help with fuctions which return the total nuber of rows in a table.
And then how I could access the table row at a time SELECT the required fields again seperated by '|' or into 5 variables until I reach the last row ..

I am using a FLASH (GUI) calling php / MySQL returning variable(s) to FLASH

Any Help would be really appreciated

 
Let me see if I have this right,

flash->php->mysql

so your PHP page should contain the following code:
$result=mysql_query("select field1,field2,field3,field4,field5 FROM yourtable");

now you have everything from the 5 fields for every row and you need to sort it into useable bits.

while($row=mysql_fetch_array($result)){

//show the output back to the php page that requested it
// and hope that thios makes it clear how to address the
// results of the query :)
echo &quot;$row[0]|$row[1]|$row[2]|$row[3]|$row[4]<br>&quot;;

}
______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
hi

is this what are you looking for?

function GetTableDataSeparated()
{
$result = mysql_query(&quot;select concat_ws('|', col1, col2, col3, col4, col5) from table&quot;);
while ($row = mysql_fetch_row($result)) {
($string!='')?$string .= &quot;|&quot;.$row[0]:$string=$row[0];
}
return $string;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top