Jump to content

[SOLVED] Help with MYSQL query in HTML


mytek

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/86501-solved-help-with-mysql-query-in-html/
Share on other sites

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!

<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>

<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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.