I got totally stuck on this last bit of code for the search function I'm building ... any suggestions on how to solve this puzzle much appreciated (I'm a complete newbie, by the way!)
Ok, here is my problem:
1. I'm using an array (string of user id's) as input into sql query (sent as post from html page, "packed" with javascript, upacked in php and converted back to array which is then used to query mysql database). It works, as far as I can tell:
for ($i = 0; ($i < count($pID)); $i++) {
$result=mysql_query("select * from $table where ClientID= '$pID[$i]' ;")
or die ("Unable to connect to database ");}
- As an output from the above I get an array of rows from the database (for matching user id). I need to extract a few (3) colums from that array and create a new array for each (or rather output values as a list into html).
If I use: while ($row = mysql_fetch_array($result)) {
echo "<font face=\"Arial, Helvetica, sans-serif\" size=\"-1\"><a href=\"javascript:getit('".$row[Name] ."')\">".$row[Name] ."</a></font><br>";
}
I can output rows of html code, not a problem. However, I can't figure out how to write to html to create a new array... for example :
var a = new Array ( - this is all html code
<? php
here goes php code to create a list a of Names, ie to ouput something like this:
one,
two,
three
where "one", "two" etc are values from "Name" column and equivalent array row in $result
note commas, if i=0 no ending comma, also no comma at the end
?>
); - back to html code
I hope my explanation is not too confusing... Thanks!