Reputation: 131
I have a database called resources
and a table inside that database called resources
. I am trying to display some content and having some trouble. This is the code I am using:
mysql_connect('localhost', 'username', 'password', 'resources');
$query = mysql_query('SELECT * FROM resources WHERE iss = 1 ORDER BY added DESC');
$company = 'company';
while ($rows = mysql_fetch_assoc($query)) {
echo "Company: " . $rows[$company];
}
Upvotes: 0
Views: 53
Reputation: 505
A few things:
div
tag.mysql_select_db
, not by adding the fourth parameter to mysql_connect
.This all also assumes your connections are working properly and everything is installed fine. Then, you should be able to get it working with something closer to this:
<div id="section_content">
<?php
mysql_connect('localhost', 'username', 'password');
mysql_select_db('resources');
$query = mysql_query('SELECT * FROM resources WHERE iss = 1 ORDER BY added DESC');
$company = 'company';
while($rows = mysql_fetch_assoc($query)){
echo "Company: " .$rows[$company];
}
?>
</div>
Upvotes: 2