Hi there,

Well after a few hours roaming around various websites I am at a loss.
Here is what I am trying to do:

1) Access a MySQL database which contains 1 table
2) Read the records from this table
3) Store the values returned from this table into javascript array
elements, ie, if I get the values "dog", "cat" and "cow" back I want
these stored in an array as such:
myArray[0] = valueReturned1
myArray[1] = valueReturned2
myArray[2] = valueReturned3

You get the idea.

Problem being that I cannot work out how to implement the javascript
section of this. At the moment my php script writes the values returned
from the database to screen but I require these to be stored in a
javascript array. Please can someone help me before I go mad :)

Here is my current .php script:

<title>Menus test</title>
<body bgcolor="white">

$dbhost = 'localhost';
$dbuser = 'guest';
$dbpass = 'guest';
$dbname = 'IFE';
$dbtable = 'menus';

//------ DATABASE CONNECTION --------//
   or die ("Unable to connect to database");

   or die ("Unable to select database");

$sql    = "SELECT * FROM $dbtable";
$result = mysql_query($sql);

$number = mysql_numrows($result);

$i = 0;

if ($number == 0)
   print "Error - No records found";
elseif ($number > 0)
   while ($i < $number)
      $text = mysql_result($result, $i, "name");
      print "$text";




Thanks, Neil


PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to