As foreach is a language-construct you cannot concat it to a string. try something like:
$temp = '.....'; foreach ( $array AS $key ) $temp .= '....'.$key.'....'; $temp .= '....'; instead --red [...] > Hi All, > > I am having a logic problem. (insert jokes here) I am trying to create a > function that will allow me to pass any number of fields and tables into a > blanket query. > > I am getting an error; Unexpected foreach. I have tried placing the loop > in several different places and am getting the same error. > > What should I be doing differently? > > Here's my code; > > function myselect($array1, $array2){ > $i = 0; > $n = 0; > $query = "SELECT".foreach($array1 as $flds){ > $flds[$i]; > }. > "FROM".foreach($array2 as $tbls){ > $tbls[$n]; > }.; > $result = mssql_query($query); > print "<table width=\"100%\" border=\"1\"> > <tr>"; > $j = 0; > while($row = mssql_fetch_array($result)){ > $fields = $row[flds[$j]]; > print "<td>".$fields."</td></tr>"; > } > } > > > alex [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php