Jump to content

[SOLVED] PHP Array from SQL Help


skylab001

Recommended Posts

I'm a total newbie at this, and still trying to get my head around the basics.  I have bought a few books to help me learn but they just don't explain everything.  I have started to just write very basic scripts as I'm learning.

 

I have been trying to write a script that will pull email addresses from my website SQL database and display them as an array on a page.

 

I would like it to display like this:

[email protected], [email protected], [email protected], [email protected], [email protected]

 

The emails are in a table called "test" and they have a status of 'approved' or 'declined'

 

I want to select only the emails that are 'approved'. So far my script works about 50%.  The problem is that it only seems to pull 1 email address rather than all of them.

 

maybe somebody can tell me why this is?

 

here is my code:

 

 

<?php

include "../database.php";

$query = "SELECT * FROM Test WHERE Status = 'Approved'";
     
$result = mysql_query($query) 
  or die(mysql_error());

while ($row = mysql_fetch_array($result)) {
$email_list = $row['Emails'];

}

echo $email_list;

?>

 

I've been pulling my hair out trying to get this to work so it's time I ask for help

Thanks for any that can be spared.

 

Brian

Link to comment
https://forums.phpfreaks.com/topic/74527-solved-php-array-from-sql-help/
Share on other sites

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.