will35010 Posted June 3, 2009 Share Posted June 3, 2009 I'm trying to echo out a table. I think think my problem is with escaping between the html and php. Any help would be appreciated. Thanks! function vehicleinfo() { require('opendb.php'); $query = mysqli_query($conn, "SELECT vin, plate, expire, year, make, model FROM vehicles"); while($row = mysqli_fetch_array($query)) { echo "<table width="700" border="1" align="center"> <tr> <th width="225" scope="col">" . $row['vin']"</th> <th width="228" scope="col">" . $row['year']"</th> <th width="225" scope="col">" . $row['make']"</th> </tr> <tr> <td><div align="center">" . $row['plate']"</div></td> <td><div align="center">" . $row['expire']"</div></td> <td><div align="center">" . $row['model']"</div></td> </tr> <tr> <td><div align="center">current mileage</div></td> <td><div align="center">miles until oil change</div></td> <td><div align="center">mpg</div></td> </tr> </table> <p> </p></th> </tr> </table>"; } } Quote Link to comment https://forums.phpfreaks.com/topic/160809-solved-functionhtml-help/ Share on other sites More sharing options...
wildteen88 Posted June 3, 2009 Share Posted June 3, 2009 As you start your echo within your function with a double quote you'll need to escape all double quotes within your string (example \"). Quote Link to comment https://forums.phpfreaks.com/topic/160809-solved-functionhtml-help/#findComment-848716 Share on other sites More sharing options...
ldougherty Posted June 3, 2009 Share Posted June 3, 2009 or replace your " with ' Quote Link to comment https://forums.phpfreaks.com/topic/160809-solved-functionhtml-help/#findComment-848719 Share on other sites More sharing options...
will35010 Posted June 3, 2009 Author Share Posted June 3, 2009 or replace your " with ' That's what I was just wondering if I could do. That would make it much easier than the escaping. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/160809-solved-functionhtml-help/#findComment-848722 Share on other sites More sharing options...
will35010 Posted June 3, 2009 Author Share Posted June 3, 2009 I replaced the html double quotes with single quotes, but I'm still getting an error. function vehicleinfo() { require('opendb.php'); $query = mysqli_query($conn, "SELECT vin, plate, expire, year, make, model FROM vehicles"); while($row = mysqli_fetch_array($query)) { echo "<table width='700' border='1' align='center'> <tr> <th width='225' scope='col'>" . $row['vin']"</th> <th width='228' scope='col'>" . $row['year']"</th> <th width='225' scope='col'>" . $row['make']"</th> </tr> <tr> <td><div align='center'>" . $row['plate']"</div></td> <td><div align='center'>" . $row['expire']"</div></td> <td><div align='center'>" . $row['model']"</div></td> </tr> <tr> <td><div align='center'>current mileage</div></td> <td><div align='center'>miles until oil change</div></td> <td><div align='center'>mpg</div></td> </tr> </table> <p> </p></th> </tr> </table>"; } } Quote Link to comment https://forums.phpfreaks.com/topic/160809-solved-functionhtml-help/#findComment-848726 Share on other sites More sharing options...
thebadbad Posted June 3, 2009 Share Posted June 3, 2009 You forgot concatenation dots after the $row variables. Quote Link to comment https://forums.phpfreaks.com/topic/160809-solved-functionhtml-help/#findComment-848730 Share on other sites More sharing options...
will35010 Posted June 3, 2009 Author Share Posted June 3, 2009 You forgot concatenation dots after the $row variables. That was it!!! Thanks!!! Quote Link to comment https://forums.phpfreaks.com/topic/160809-solved-functionhtml-help/#findComment-848733 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.