Jump to content

Recommended Posts

Hallo there !

Can you please help me with this simple thing I can't make work or understand:

 

mysql_connect('localhost', 'jipak', 'password');

mysql_select_db('contacts');

mysql_query('SELECT name FROM contacts');

$result = mysql_query('SELECT name FROM contacts');

$row = mysql_fetch_array($result);

 

I would like to load data from sql instead of writing it manually like this:

 

$DataArr = array("Some Notes on Jeff.", "Info on Amy", "Facts on Bob.", "Some more info on Jimmy","Some gossip about Steve.");

 

Link to comment
https://forums.phpfreaks.com/topic/98030-loading-array-with-sql-results/
Share on other sites

How about this

 

<?php
  mysql_connect('localhost', 'jipak', 'password');
  mysql_select_db('contacts');
  $result = mysql_query('SELECT name FROM contacts');
  $DataArr = array();
  while($row = mysql_fetch_array($result)){
    $DataArr[] = $row['name'];
  }
?>

Guest
This topic is now 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.