Jump to content

Archived

This topic is now archived and is closed to further replies.

ncix007

array using database

Recommended Posts

hi,
i got stuck in some where in my code:
i have created database and inserted the information as needed

i want to
display the information as an array as follows:
$admission= array();

///example written manaully

$admission[0] = array("name" => "ram", "m" => "best","id" => "item", "u1" => "");
$admission[1] = array("name" => "kam", "m" => "computer","id" => "code", "u1" => "");
$admission[2] = array("name" => "john", "m" => "jam","id" => "sku", "u1" => "");
$admission[3] = array("name" => "aanita","m" => "circuit","id" => "oid", "u1" => "");

///

i have 4 field in database table as name, m, id, u1
i want to parse the list in the above manner
can any body help me

regards
ncix007

Share this post


Link to post
Share on other sites
[code]$admissions = array();
$sql = "SELECT name, m, id, u1 FROM tablename";
$res = mysql_query ($sql) or die(mysql_error());
while ($row = mysql_fetch_assoc($res)) {
    $admissions[] = $row;
}[/code]

Share this post


Link to post
Share on other sites

×

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.