PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 28th, 2004, 07:53 AM
tarka tarka is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 15 tarka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
trying to get a four column array to align correctly in a table

can someone tell me where i'm going wrong with this....

i'm trying to loop my query results into a table and i get a very weird result. i guess its something to do with how i express the array ....i think

when i run the query in mysql i get this, which is what i'm trying to achieve....

Code:
JOB TITLE  | WITH TEL  | WITH EMAIL  | QUANTITY
-----------------------------------------------------------------------------
creative      | 555            | 499                | 2313
-----------------------------------------------------------------------------
Design       | 5575          | 5503               | 10370
-----------------------------------------------------------------------------
photo         | 32             | 18                   | 416



but when i run the query using this php script....

Code:
// open table
echo '<table width="555" height="38" border="0" cellpadding="0" cellspacing="1">';

// table header
echo '<tr bgcolor="#FF943C" class="style60 style4">';
echo '<td colspan="2" height="31" align="center">JOB TITLE</td>';
echo '<td width="92" height="31" align="center">WITH TEL</td>';
echo '<td width="92" height="31" align="center">WITH EMAIL</td>';
echo '<td width="92" height="31" bgcolor="#FF6600" align="center">QUANTITY</td>';
echo '</tr>';
 						
// begin for loop and mysql query
for ($i = 0; $i < count($job_title_id); $i++) { 
$query = "SELECT 
		p1_job_title_code.job_title_01 AS JOB_TITLE,
		SUM(CASE WHEN p1_list_creative.telephone = ' ' THEN 0 ELSE 1 END) AS WITH_TEL,
		SUM(CASE WHEN p1_list_creative.email = ' ' THEN 0 ELSE 1 END) AS WITH_EMAIL,
		COUNT(p1_job_title_code.job_title_id) AS QUANTITY 
		FROM p1_list_creative, p1_job_title_code
		WHERE p1_job_title_code.job_title_id = '".$job_title_id[$i]."'
		AND p1_list_creative.country_id = '".$country_id."'
		AND p1_list_creative.job_title_id = '".$job_title_id[$i]."'
		GROUP BY*p1_job_title_code.job_title_id";
$query_result = mysql_query($query);

$table = mysql_result($query_result,0);
				
// open table row
echo '<tr bgcolor="#FFBC79" class="style60">';			
											
// column 1 JOB TITLE 
echo '<td height="31" colspan="2" align="center" class="style60">'.$table[0].'</td>';

// column 2 WITH TEL  
echo '<td height="31" align="center" class="style60">'.$table[1].'</td>';

// column 3 WITH EMAIL 
echo '<td height="31" align="center" class="style60">'.$table[3].'</td>';
						
// column 4 QUANTITY
echo '<td height="31" align="center" class="style60">'.$table[4].'</td>';
				
// close looped table row
echo '</tr>';
				
// end for loop
}

// end table
echo '</table>';


here's what i'm getting.....

Code:
JOB TITLE  | WITH TEL  | WITH EMAIL  | QUANTITY
-----------------------------------------------------------------------------
c                | r                 | a                   | t
-----------------------------------------------------------------------------
d                | e                | i                    | g
-----------------------------------------------------------------------------
p                | h                | t                   | o


cheers!

Reply With Quote
  #2  
Old August 28th, 2004, 01:30 PM
tarka tarka is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 15 tarka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
not to worry, sorted it with this...

$table = mysql_fetch_row($query_result);

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > trying to get a four column array to align correctly in a table


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT