mytek Posted January 17, 2008 Share Posted January 17, 2008 I'm trying to query from a MYSQL database and lay it out in a nice HTML format. Can you please see the example and recommend a good way? <html> <head> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Phone Extension/Numbers</title> </head> <body> <p align="center"> <img border="0" src="images/ag_logo.jpg" width="257" height="103"></p> <p align="center"><u><font face="Arial"><b>Phone Extension/Numbers</b></font></u></p> <div align="center"> <?php $mysqlLink = mysql_connect( 'localhost' , '***' , '****' ); mysql_select_db( 'phonebook' , $mysqlLink ); $sql = 'SELECT * FROM cs_phonebook'; $result = mysql_query( $sql ); while( $row = mysql_fetch_array( $result ) ) { echo $row[ 'lname' ] . $row[ 'fname' ]; } mysql_close( $mysqlLink ); ?> <table border="1" width="48%" id="table1" bordercolor="#000000" cellspacing="0"> <tr> <td width="170" bgcolor="#C0C0C0"><b>Last Name</b></td> <td width="153" bgcolor="#C0C0C0"><b>First Name</b></td> <td width="54" bgcolor="#C0C0C0"><b>Ext</b></td> <td bgcolor="#C0C0C0"><b>DID</b></td> <td width="146" bgcolor="#C0C0C0"><b>Mobile</b></td> </tr> <tr> <td width="170" height="26"> </td> <td width="153" height="26"> </td> <td width="54" height="26"> </td> <td height="26"> </td> <td width="146" height="26"> </td> </tr> <tr> <td width="170" height="26"> </td> <td width="153" height="26"> </td> <td width="54" height="26"> </td> <td height="26"> </td> <td width="146" height="26"> </td> </tr> </table> </div> <div align="center"> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/86501-solved-help-with-mysql-query-in-html/ Share on other sites More sharing options...
revraz Posted January 17, 2008 Share Posted January 17, 2008 Does everything work? Are you just looking for layout design? Quote Link to comment https://forums.phpfreaks.com/topic/86501-solved-help-with-mysql-query-in-html/#findComment-441997 Share on other sites More sharing options...
mars_rahul Posted January 17, 2008 Share Posted January 17, 2008 why dont u try Template engines so that u can clearly differentiate your php and html pages. such as Xtemplate Template engines for small projects and SMARTY for big projects. Good Luck. Quote Link to comment https://forums.phpfreaks.com/topic/86501-solved-help-with-mysql-query-in-html/#findComment-442022 Share on other sites More sharing options...
mytek Posted January 22, 2008 Author Share Posted January 22, 2008 Does everything work? Are you just looking for layout design? I understand the query part, but trying to fit it in the HTML layout I have. So yes, the layout is the issue. If you can pop that code up you will see my query, but I can't get it in my layout. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/86501-solved-help-with-mysql-query-in-html/#findComment-446296 Share on other sites More sharing options...
rhodesa Posted January 22, 2008 Share Posted January 22, 2008 <html> <head> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Phone Extension/Numbers</title> </head> <body> <p align="center"> <img border="0" src="images/ag_logo.jpg" width="257" height="103"></p> <p align="center"><u><font face="Arial"><b>Phone Extension/Numbers</b></font></u></p> <div align="center"> <table border="1" width="48%" id="table1" bordercolor="#000000" cellspacing="0"> <tr> <td width="170" bgcolor="#C0C0C0"><b>Last Name</b></td> <td width="153" bgcolor="#C0C0C0"><b>First Name</b></td> <td width="54" bgcolor="#C0C0C0"><b>Ext</b></td> <td bgcolor="#C0C0C0"><b>DID</b></td> <td width="146" bgcolor="#C0C0C0"><b>Mobile</b></td> </tr> <?php $mysqlLink = mysql_connect( 'localhost' , '***' , '****' ); mysql_select_db( 'phonebook' , $mysqlLink ); $sql = 'SELECT * FROM cs_phonebook'; $result = mysql_query( $sql ); while( $row = mysql_fetch_array( $result ) ) { ?> <tr> <td width="170" height="26"><?php echo $row[ 'lname' ];?></td> <td width="153" height="26"><?php echo $row[ 'fname' ];?></td> <td width="54" height="26"> </td> <td height="26"> </td> <td width="146" height="26"> </td> </tr> <?php } mysql_close( $mysqlLink ); ?> </table> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/86501-solved-help-with-mysql-query-in-html/#findComment-446302 Share on other sites More sharing options...
mytek Posted January 22, 2008 Author Share Posted January 22, 2008 <html> <head> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Phone Extension/Numbers</title> </head> <body> <p align="center"> <img border="0" src="images/ag_logo.jpg" width="257" height="103"></p> <p align="center"><u><font face="Arial"><b>Phone Extension/Numbers</b></font></u></p> <div align="center"> <table border="1" width="48%" id="table1" bordercolor="#000000" cellspacing="0"> <tr> <td width="170" bgcolor="#C0C0C0"><b>Last Name</b></td> <td width="153" bgcolor="#C0C0C0"><b>First Name</b></td> <td width="54" bgcolor="#C0C0C0"><b>Ext</b></td> <td bgcolor="#C0C0C0"><b>DID</b></td> <td width="146" bgcolor="#C0C0C0"><b>Mobile</b></td> </tr> <?php $mysqlLink = mysql_connect( 'localhost' , '***' , '****' ); mysql_select_db( 'phonebook' , $mysqlLink ); $sql = 'SELECT * FROM cs_phonebook'; $result = mysql_query( $sql ); while( $row = mysql_fetch_array( $result ) ) { ?> <tr> <td width="170" height="26"><?php echo $row[ 'lname' ];?></td> <td width="153" height="26"><?php echo $row[ 'fname' ];?></td> <td width="54" height="26"> </td> <td height="26"> </td> <td width="146" height="26"> </td> </tr> <?php } mysql_close( $mysqlLink ); ?> </table> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/86501-solved-help-with-mysql-query-in-html/#findComment-446389 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.