echo several rows and column of mysql query with php -
i echo rows , column mysql query search, here current php:
<?php header("content-type: text/plain"); mysql_connect('localhost','root','') or die('cannot connect mysql server'); mysql_select_db('dbchemalive') or die('cannot connect database'); $inputdata=(isset($_get["data"])) ? $_get["data"] : null; $data=mysql_real_escape_string(filter_var($inputdata, filter_sanitize_special_chars)); $q=mysql_query("select comptype, method, base geoandenergies smiles='".$data."' ") or die(mysql_error()); $n=mysql_num_rows($q); //not mysql_fetch_row, not return count array if($n>0) { // $info=mysql_fetch_row($q); $val=''; while($info=mysql_fetch_row($q)) { if($val!='') $val.=' < '; $val.= $info[0]; } echo $val; } ?>
it echoing row1col1 < row2col1 < .... rowncol1, row1col1 < row1col2 < .... < row2col1 < row2col2... rows , columns
how can that?
thanks
try this. have adapt little(formatting)
while($info = mysql_fetch_row($q)) { if($val != '' ){ $val.=' < '; } foreach($info $key => $value){ $val .= $value . ' < '; } }
Comments
Post a Comment