We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

PHP query into multiple column table

Albee_J
Albee_J asked
on
Medium Priority
364 Views
Last Modified: 2012-05-11
I have a db table that stores statistics for page view on our techcells.  

"select statDate, views from techcellStats WHERE techcellID = '$techcellID' ";

I need to spit that data out into an html table that shows horizontally

column headings:  Jan.      Feb.       Mar.        April    
                              Views  views  views    views    


Comment
Watch Question

Mohamed AbowardaSenior Software Engineer
CERTIFIED EXPERT
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
Thanks Medo, I will check the link out tomorrow at work

Author

Commented:
Table is displaying but I cannot get techcellID to pass into the query correctly...  I am using a drop down list to select what to view

function display_db_table($tablename, $connection,
$header_bool, $table_params)
{
$query_string = "SELECT * FROM techcellView WHERE techcellID = '$techcellID' ";
display_db_query($query_string, $connection,
$header_bool, $table_params);
}
?>

Senior Software Engineer
CERTIFIED EXPERT
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
Getting these errors: see screenshot




error.JPG
Mohamed AbowardaSenior Software Engineer
CERTIFIED EXPERT

Commented:
According to the function you posted, you didn't assigned a value to $techcellID, therefore it's undefined.

You need to assign a value to $techcellID, so SQL will query about it, here is example:
function display_db_table($tablename, $connection, $header_bool, $table_params)
{
$techcellID = 1; // Now $techcellID is defined
$query_string = "SELECT * FROM techcellView WHERE techcellID = $techcellID";
display_db_query($query_string, $connection,
$header_bool, $table_params);
}

Open in new window

Author

Commented:
Got it thanks!  I had to slightly modify
$techcellID = $_GET['techcells'];
Mohamed AbowardaSenior Software Engineer
CERTIFIED EXPERT

Commented:
You are welcome! :)

Author

Commented:
Do you have any idea how I could make the Stat Dats display horizontally with the views underneath?

This is how it looks now.


techcells.jpg
Mohamed AbowardaSenior Software Engineer
CERTIFIED EXPERT
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
great thanks!
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.