Jump to content

Array and Exploding Not Outputting Correctly


silveradogirl45

Recommended Posts

I have a database table with a lot of rows and columns. I'm trying to pull one column out of the database. Put the files into an array. And pull each value out.

 

My current code is outputting this:

$cars[0]="FordChevyToyota";

$cars[1]="";

$cars[2]="";

 

 

I want my code to ouput this instead:

$cars[0]="Ford";

$cars[1]="Chevy";

$cars[2]="Toyota";

 

I know it's probably simple, but for some reason I can't get it to output correctly from the database.

 

$result = mysql_query("SELECT column1 from Table);

	while ($row = mysql_fetch_array($result)) {

	$files = $row[column1];

	$cars = array($files);

	echo $array[0];

	}

 

When I echo $array[0] it prints "FordChevyToyota".

When I echo $row[column1] it prints "FordChevyToyota".

When I echo $files[0] it prints "FFF";

 

Thanks in advance for any help!

 

 

 

 

I still have the problem, but I noticed I made a typo in my initial post. the echo isn't suppose to be $array[0]; it's suppose to be $cars[0] that outputs "FordChevyToyota". Just wanted to clarify that confusion to anyone trying to help.

 

Sorry!

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.