Here is my code and it is going through my results. Problem is it lists the one row in my db table five times. There is the id, name, email, company, and title. How do I just show my result once?
$sql = "SELECT * FROM `newsletter`";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {
foreach ($row as $key => $value) {
$DATA .= "
<div id='contentBox'>
Name: $row[Name]<br />
Email: $row[Email]<br />
Company: $row[Company]<br />
Title: $row[Title]<br />
<br />
</div>
";
}
}
Get rid of the foreach loop, you don’t need it.
Remember that you’re getting back rows (with multiple columns) from the database.
Your
whileloop iterates “down” that table, where each$rowis a row in the database. Doing aforeachon the$rowwill iterate over each column individually.