• 0

[PHP/MySQL] MySQL to Array


Question

5 answers to this question

Recommended Posts

  • 0
$connection = mysql_connect($db_host, $db_user, $db_pass) or die(mysql_error());
$db = mysql_select_db($db_name, $connection) or die(mysql_error());
$sql= "SELECT * FROM $table";
$sql_results = mysql_query($sql, $connection) or die("Couldn't execute query");

while($row=mysql_fetch_array($sql_results, MYSQL_ASSOC))
	$arr[]=$row;

  • 0

Thanks for the fast reply,

I should have been more clear as to what I was looking to accomplish,

here is a picture of my database, and a highlited column, I want to select only the date and one column at a time!

Thanks for the fast reply!

-Ax

post-66301-1106529987_thumb.jpg

  • 0

Well you can acomplish it like this:

<?php
// Connect and stuff
$query = "SELECT date, t_air FROM kcwks_raw";
$result = mysql_query( $query );
$data = array();
while( $row = mysql_fetch_array( $result ) )
     $data[] = array( $row[0], $row[1] );
// Disconnect
?>

then on data you will have a array were each item is an array with the data you need..

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.