generating a set of javascript code using php
<p>I´m trying using php to generate a set of "{URL.callback}" to use in javascript. By using database. Here is my code:</p>

<pre><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"] })";
</code></pre>

<p>This is the code it returns:</p>

<pre><code>({ t:"", r:["example1", "example2", "example3",] })
</code></pre>

<p>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.</p>

<p>The question is: How to generate it correctly ? How to get rid the last (,) ?</p>
