Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-13-2013, 06:57 AM   PM User | #1
gayathri
New Coder

 
Join Date: Nov 2012
Location: chennai
Posts: 55
Thanks: 29
Thanked 0 Times in 0 Posts
gayathri is an unknown quantity at this point
How to store row/column of mysql data in array

Hi,
Please tell me how to store a column from db in array.
My table name is qtype, and the fields in table are id & type.

PHP Code:
$sql="select type from qtype";
$result=mysql_query($sql); 
I had selected the type from table.
There are some 6types in type field, and i have to store all the 6 in array.
How shall i do this. Any ideas please tell me.

Last edited by gayathri; 02-13-2013 at 11:55 AM..
gayathri is offline   Reply With Quote
Old 02-13-2013, 08:08 AM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,678
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
PHP Code:
$sql="select type from qtype";
$result=mysql_query($sql) or die(mysql_error()); 
while(
$row=mysql_fetch_assoc($result)){
$arrType=$row['type'];
}

print_r($arrType); 
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Users who have thanked abduraooft for this post:
gayathri (02-13-2013)
Old 02-13-2013, 08:13 AM   PM User | #3
gayathri
New Coder

 
Join Date: Nov 2012
Location: chennai
Posts: 55
Thanks: 29
Thanked 0 Times in 0 Posts
gayathri is an unknown quantity at this point
Thanks for the reply Abduraooft.
I got the result.
Now I am having another column in same table. I need to compare both. I have to chech like if the type is in the array(), some conditions will have to do. How shall i do this. please tell me.
gayathri is offline   Reply With Quote
Old 02-13-2013, 10:44 AM   PM User | #4
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,678
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Quote:
I have to chech like if the type is in the array(), some conditions will have to do. How shall i do this. please tell me.
Please explain your ultimate aim.
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 02-13-2013, 11:55 AM   PM User | #5
gayathri
New Coder

 
Join Date: Nov 2012
Location: chennai
Posts: 55
Thanks: 29
Thanked 0 Times in 0 Posts
gayathri is an unknown quantity at this point
My ultimate aim is, I've already stored my type in another variable($var2). Just i need to check whether this $var2 is in the $arrType. I did it and the solution is
PHP Code:
for($i=0$i<6;$i++){
if(
$var[$i]==$str)
{
    echo 
"welcome----".$str;
        
$a=a.php;

Now i have to include another php file inside this if condition, storing the php file name in some variable like $a=a.php. and when clicking, it have to open the corresponding ouput in a.php file needed.
Any ideas please tell me.
gayathri is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:01 AM.


Advertisement
Log in to turn off these ads.