I´m trying using php to generate a set of "{URL.callback}" to use in javascript. By using database. Here is my code:
$sql="select * from search where keywords LIKE '$bb%' ORDER BY keywords ";
$result=mysql_db_query($dbname,$sql);
echo $_GET["callback"] . "({ t:\"$t\", r:[";
while ( $rs=mysql_fetch_array($result)) {
$keywords=$rs[keywords];
echo "" ."\"$keywords\"".","." ";
}
echo"] })";
This is the code it returns:
({ t:"", r:["example1", "example2", "example3",] })
Everything seemed to be correct except the (,) in the end (after "example3") that I want to get rid. because it´s not correct and can not be use with that.
The question is: How to generate it correctly ? How to get rid the last (,) ?