Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
How to Dispaly Mysql Query in two columns based on database field
Old 05-04-2009, 05:54 AM How to Dispaly Mysql Query in two columns based on database field
Junior Talker

Posts: 1
Trades: 0
I am using this query to obtain data from mysql

"select Code_Desc, Code_Type from code order by Code_Type"

Code_Type contains "R" or "P", I want to shown R and P data in two columns, all P Records may be in first column and all R records may be in 2nd columns.
Any idea how to do in php?
mfdarvesh is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-04-2009, 07:04 AM Re: How to Dispaly Mysql Query in two columns based on database field
dark_lord's Avatar
Experienced Talker

Posts: 41
Name: Parijat Roy
Location: INDIA-KOLKATA
Trades: 0
PHP Code:
<?php
echo "<table><tr>";

$sql mysql_query("SELECT Code_Desc, Code_Type FROM code ORDER BY Code_Type");
while(
$item=mysql_fetch_array($sql))
{
    
//$item[0] is the Code_Desc
     
if($item[1]=="R")
     {
          echo 
"<td></td>";//empty the first column which contains P
          
echo "<td>echo $item[1]</td>";
     }else if(
$item[1]=="P")
     {
           echo 
"<td>echo $item[1]</td>";
           echo 
"<td></td>";//empty the second column which contains R
     
}
}
echo 
"</tr></table>";
?>
i hope this works!! let me know what you get with this code!!!
__________________
I AM THE BEAUTIFUL NIGHTMARE

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by dark_lord; 05-04-2009 at 07:05 AM.. Reason: missed out some text
dark_lord is offline
Reply With Quote
View Public Profile Visit dark_lord's homepage!
 
Reply     « Reply to How to Dispaly Mysql Query in two columns based on database field
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.35801 seconds with 12 queries