Page 1 of 1

How can i select multiple values from DB..?

Posted: Mon Oct 05, 2009 5:12 am
by dilruk83
This is my table which contain two column named router and routet_Desc.
-----------------------
router routet_Desc
r1 a
r1 b
r1 c
r1 d

Then i wanna select that all routet_Desc according to router name.How can i do that..?
If i select r1 result should be a,b,c,d.I wanna put those result to array.How can i do that..?
if $router=array();

i wanna get $router[0]=a ,$router[1]=b.......etc


Please help me to do this..

Thanking you alll

Re: How can i select multiple values from DB..?

Posted: Mon Oct 05, 2009 10:49 am
by robnet
What have you got so far?

What database are you using?

Re: How can i select multiple values from DB..?

Posted: Mon Oct 05, 2009 11:13 pm
by dilruk83
This is my query for mysql Database
$Select_VirtualRouters=mysql_query("SELECT routet_Desc FROM table_name WHERE router='r1' ");

while (list($vrouter)=mysql_fetch_array($Select_VirtualRouters))
{
echo $vrouter;
}


I got the out put : abcd , that is mean all router_Desc as list/string.

but i wanna get out put as array. That is mean Myarray[0]=a , Myarray[1]=b ,Myarray[2]=c ,Myarray[3]=d

because i'm going to assign those router_Desc to four string variables.

Thank you

Re: How can i select multiple values from DB..?

Posted: Tue Oct 06, 2009 2:38 am
by robnet
Try changing your while loop to this:

Code: Select all

while ($result=mysql_fetch_array($Select_VirtualRouters)) {
 Myarray[]=$result['routet_Desc'];
}

Re: How can i select multiple values from DB..?

Posted: Tue Oct 06, 2009 11:42 pm
by dilruk83
Thank you very much friend......it was grt......really thanking you again..



Wishing you all the best in future...


TC..