Jump to content

rows inside array


violinrocker

Recommended Posts

i was wonderin if there is a function where you can get a column in an array format... if there is none, how could I put a row of names inside an array.

  @include ("../session.php");
  include ("../addons/functions/general.php");
mysql_connect("localhost", "", "") or die(mysql_error());
					mysql_select_db("") or die(mysql_error());

$result = mysql_query("SELECT friendname FROM  friends where username='$session->username'");
while ($row = mysql_fetch_assoc($result)) {  } 

$response = array();
$names = array('ROW of NAMES in HERE);

 

i need $names = array('ROW of Names in Here); to be like this

$names = array('Abraham Lincoln', 'Adolf Hitler', 'Agent Smith', 'Agnus', 'AIAI', 'Akira Shoji', 'Akuma', 'Alex', 'Antoinetta Marie', 'Baal', 'Baby Luigi', 'Backpack', 'Baralai', 'Bardock', 'Baron Mordo', 'Barthello', 'Blanka', 'Bloody Brad', 'Cagnazo', 'Calonord', 'Calypso', 'Cao Cao', 'Captain America', 'Chang', 'Cheato', 'Cheshire Cat', 'Daegon', 'Dampe', 'Daniel Carrington', 'Daniel Lang', 'Dan Severn', 'Darkman', 'Darth Vader', 'Dingodile', 'Dmitri Petrovic', 'Ebonroc', 'Ecco the Dolphin', 'Echidna', 'Edea Kramer', 'Edward van Helgen', 'Elena', 'Eulogy Jones', 'Excella Gionne', 'Ezekial Freeman', 'Fakeman', 'Fasha', 'Fawful', 'Fergie', 'Firebrand', 'Fresh Prince', 'Frylock', 'Fyrus', 'Lamarr', 'Lazarus', 'Lebron James', 'Lee Hong', 'Lemmy Koopa', 'Leon Belmont', 'Lewton', 'Lex Luthor', 'Lighter', 'Lulu');

Link to comment
https://forums.phpfreaks.com/topic/236120-rows-inside-array/
Share on other sites

in my table i have the names "smiley,jc,dub,cookie,pete"

what i wanted to do was fetch them from the database and put them inside $names = array(smiley,jc,dub,cookie,pete);

sorta like

$names = array( while ($row = mysql_fetch_assoc($result)) {  return $row[name] } );

Link to comment
https://forums.phpfreaks.com/topic/236120-rows-inside-array/#findComment-1213927
Share on other sites

in my table i have the names "smiley,jc,dub,cookie,pete"

what i wanted to do was fetch them from the database and put them inside $names = array(smiley,jc,dub,cookie,pete);

sorta like

$names = array( while ($row = mysql_fetch_assoc($result)) {  return $row[name] } );

 

That's exactly what I gave you :)

 

Put what I posted inside your while loop, and it will put each db name into the names array

Link to comment
https://forums.phpfreaks.com/topic/236120-rows-inside-array/#findComment-1213931
Share on other sites

that would make it something like

$names = array('smiley','hanane','dub');

 

or will it be something like

$names = array[smileyhananedub];

 

sorry if im so stupid with this, im not well versed with arrays

 

coz if i manually put the names like

$names = array('Abraham Lincoln', 'Adolf Hitler', 'Agent Smith', 'Agnus', 'AIAI', 'Akira Shoji', 'Akuma', 'Alex', 'Antoinetta Marie', 'Baal', 'Baby Luigi', 'Backpack', 'Baralai', 'Bardock', 'Baron Mordo', 'Barthello', 'Blanka', 'Bloody Brad', 'Cagnazo', 'Calonord', 'Calypso', 'Cao Cao', 'Captain America', 'Chang', 'Cheato', 'Cheshire Cat', 'Daegon', 'Dampe', 'Daniel Carrington', 'Daniel Lang', 'Dan Severn', 'Darkman', 'Darth Vader', 'Dingodile', 'Dmitri Petrovic', 'Ebonroc', 'Ecco the Dolphin', 'Echidna', 'Edea Kramer', 'Edward van Helgen', 'Elena', 'Eulogy Jones', 'Excella Gionne', 'Ezekial Freeman', 'Fakeman', 'Fasha', 'Fawful', 'Fergie', 'Firebrand', 'Fresh Prince', 'Frylock', 'Fyrus', 'Lamarr', 'Lazarus', 'Lebron James', 'Lee Hong', 'Lemmy Koopa', 'Leon Belmont', 'Lewton', 'Lex Luthor', 'Lighter', 'Lulu');

 

a javascript that fetches the name works... but if i tried fetching from the database, it doesnt work

Link to comment
https://forums.phpfreaks.com/topic/236120-rows-inside-array/#findComment-1213934
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.