Forum Moderators: coopster
<?php
include 'connection.inc';
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM my_database WHERE category='10' ORDER BY field1-name ASC";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "<table border='0' cellspacing='2' cellpadding='2'>
<tr>
<th><h3>Value1</h3></th>
<th><h3>Value2</h3></th>
<th><h3>Value3</h3></th>
<th><h3>Value4</h3></th>
<th><h3>Value5</h3></th>
</tr>;
$i=0;
while ($i < $num) {
<tr>
<td><b><? echo $field1-name;?></b></td>
<td><b><? echo $field2-name;?></b></td>
<td><b><? echo $field3-name;?></b></td>
<td><b><? echo $field4-name;?></b></td>
<td><b><? echo $field5-name;?></b></td>
</tr>
<?
$i++;
}
echo "</table>";
?>
#make sure this is parsed as php and not displayed as regular text!
#you might want to change it to connection.inc.php to be sure
include 'connection.inc';
#
#localhost needs to be a string - added quotes
mysql_connect('localhost',$username,$password);
mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM my_database WHERE category='10' ORDER BY field1-name ASC";
$result = mysql_query($query);
#
echo "<table border='0' cellspacing='2' cellpadding='2'>
<tr>
<th><h3>Value1</h3></th>
<th><h3>Value2</h3></th>
<th><h3>Value3</h3></th>
<th><h3>Value4</h3></th>
<th><h3>Value5</h3></th>
</tr>";#added a quote at the end here
#
while ($row = [url=http://www.php.net/mysql-fetch-assoc]mysql_fetch_assoc[/url]($result)) {
?>
<tr>
<td><b><? echo $row[$field1-name];?></b></td>
<td><b><? echo $row[$field2-name];?></b></td>
<td><b><? echo $row[$field3-name];?></b></td>
<td><b><? echo $row[$field4-name];?></b></td>
<td><b><? echo $row[$field5-name];?></b></td>
</tr>
<?
}
#
mysql_close();
echo "</table>";
Try that to see what you get. Take note of all the comments in there; there were many errors.
If you have further problems, post the results, and please give the errors that the script is producing, as well.
Good luck! :)