syntax - a small issue with mysql -


i'm started learn php & mysql, wanna know what's wrong

function show(){ $query=mysql_query(" select * family "); if (!$query) {     die("invalid query ".mysql_error()); } while ($row=mysql_fetch_array($query)) { echo    "<tr>  line 24 ===><td><?php echo $row['id']; ?></td>             <td><?php echo $row['name']; ?></td>             <td><?php echo $row['lname']; ?></td>         </tr>";     } } 

as can see have function show data fields, , have table in page want including & calling function,my variables appear in table,but keep getting stupid error: plz

parse error: syntax error, unexpected '' (t_encapsed_and_whitespace), expecting identifier (t_string) or variable (t_variable) or number (t_num_string) in c:\xampp\htdocs\php\lib.php on line 24

for wanna suggest below code:

echo    "<tr>             <td>". $row['id'] ."</td>             <td>". $row['name'] ."</td>             <td>". $row['lname'] ."</td>         </tr>";  

i did try , works wont show date in table rows purpose of want show each data variables in table row, other way know?

change <td><?php echo $row['id']; ?></td> <td>".$row['id']."</td>

you're trying bring php code inside string, won't work. concatinate strings using 'dot' operator. take here more information.

edit requested:

echo "<table>"; while ($row=mysql_fetch_array($query)) {   echo "<tr>     <td>".$row['id']."</td>     <td>".$row['name']."</td>     <td>".$row['lname']."</td>   </tr>"; } echo "</table>"; 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -