| | |
show club presidents info hide everyone else's
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Jun 2008
Posts: 62
Reputation:
Solved Threads: 3
The names and offices show up properly, but none of the contact info shows up, wether logged in or not. I would assume that the sql query's are working fine, just the if logged in and if officer aren't working.
I do appreciate the help!
I do appreciate the help!
There are alot of people smarter than me, BUT at least I try to be of some help. Of coarse I'm not perfect, I need help too.
•
•
Join Date: Aug 2008
Posts: 381
Reputation:
Solved Threads: 33
Okay, I came in after-the-fact on this post and now I'm going to back up and take it from the start ... wish me luck.
First of all you need to test and make certain you have a 'true' value for session status when a member is logged in. That could be your only problem right now.
Please check my code to make sure all of your database login and table field names are correct -- change my code values if they are not
And check that the SESSION names-values are correct, and working
Okay, my eyes are so blurry I can't read...hope I didn't make too many type-os
Ciao
First of all you need to test and make certain you have a 'true' value for session status when a member is logged in. That could be your only problem right now.
Please check my code to make sure all of your database login and table field names are correct -- change my code values if they are not
And check that the SESSION names-values are correct, and working
PHP Syntax (Toggle Plain Text)
<?php include( './config/db.php' ); $sub_name = $_GET['sub_name']; // If it's a form value, you probably want to use $_POST['sub_name'] with <form method="POST"> $officers = array( "President", "Vice President", "Secretery" ); // edit to suite your needs ... session_start(); $session = ( $_SESSION['auth']['status'] == 1 ) ? TRUE : FALSE; // or ? ... ( $_SESSION['User']['status'] == 1 ) $link = @mysql_connect( $host, $user, $pass ) or die( mysql_error() ); @mysql_select_db( $dbase ) or die( mysql_error() ); // make sure these are the names of the fields in your database, change them in // the $sql query `email` (etc) and the $obj->email values (bellow) if they are not ... $sql = "SELECT `fname`, `lname`, `sub_office`, `email`, `homephone`, `cellphone`, `address`, `city`, `state`, `zip` FROM `MembersTable` WHERE sub_name='$sub_name'"; // You can just use this, if thesse are all or most of the values in the table ... // $sql = "SELECT * FROM `MembersTable` WHERE sub_name='$sub_name'"; $result = mysql_query( $sql ) or die( mysql_error() ); $html = ''; while ( $obj = mysql_fetch_object( $result ) ) { $html .= <<<ENDHTML <tr> <td>$obj->sub_office</td> <td>$obj->fname $obj->lname</td> ENDHTML; if ( $session || in_array( $obj->sub_office, $officers ) ) { $html .=<<<ENDHTML <td>$$obj->hphone / $cphone</td> <td>$$obj->email</td> <td>$$obj->address, $$obj->cty, $$obj->state $$obj->zip</td> <td>$$obj->sub_name</td> ENDHTML; } $html .= " <\tr>\n"; } $title = "<title>Officers of the $sub_name Subordinate Grange</title>"; ?> <?php include("./config/header.php"); ?> </head> <body> <table width="85%" border="1" class="main"> <tbody> <tr> <td colspan="6"><h2>Officers of <? echo "$sub_name"; ?> Subordinate Grange</h2></td> </tr> <tr> <td><b>Office</b></td> <td><b>Officer</b></td> <td><b>Home / Cell Phone #</b></td> <td><b>Email</b></td> <td><b>Address</b></td> <td><b>Subordinate Grange</b></td> </tr> <?php print $html; ?> <tr> <td colspan="6"><!-- C. FOOTER AREA --> <div class="footer"> <?php include ('./config/footerinfo.php'); ?> </div></td> </tr> </tbody> </table> </body> </html>
Okay, my eyes are so blurry I can't read...hope I didn't make too many type-os
Ciao
•
•
Join Date: Jun 2008
Posts: 62
Reputation:
Solved Threads: 3
Hi, yours seems to be really close except:
There is a bunch of < r> before the table (I can't find where they are coming from),
I also would like to insert into a cell if the sql row is empty for that column (to make the table look better)
I did have to make a couple of changes to make things work, but this is the closest I've gotten yet.
I added the SELECT CASE so I could order the offices in a set order.
I do have the 'sub_name' sent from a form currently, but I don't want to switch it to the POST method. I want to keep it so I can make a link and have it go directly to a certain one, therefore I believe it should stay as GET.
Thanks for all your help so far.
There is a bunch of < r> before the table (I can't find where they are coming from),
I also would like to insert into a cell if the sql row is empty for that column (to make the table look better)
I did have to make a couple of changes to make things work, but this is the closest I've gotten yet.
PHP Syntax (Toggle Plain Text)
<?php include( './config/db.php' ); $sub_name = $_GET['sub_name']; // If it's a form value, you probably want to use $_POST['sub_name'] with <form method="POST"> $officers = array( "Master - President", "Overseer - Vice President", "Secretery", "Lecturer - Program Director" ); // edit to suite your needs ... session_start(); $session = ( $_SESSION['auth']['status'] == 1 ) ? TRUE : FALSE; // or ? ... ( $_SESSION['User']['status'] == 1 ) $link = @mysql_connect( $server, $dbusername, $dbpassword ) or die( mysql_error() ); @mysql_select_db( $db_name ) or die( mysql_error() ); // make sure these are the names of the fields in your database, change them in // the $sql query `email` (etc) and the $obj->email values (bellow) if they are not ... $sql = "SELECT `fname`, `lname`, `sub_office`, `email`, `homephone`, `cellphone`, `address`, `city`, `state`, `zip`, (SELECT CASE WHEN `sub_office` = 'Master - President' THEN 1 WHEN `sub_office` = 'Overseer - Vice President' THEN 2 WHEN `sub_office` = 'Lecturer - Program Director' THEN 3 WHEN `sub_office` = 'Steward' THEN 4 WHEN `sub_office` = 'Assistant Steward' THEN 5 WHEN `sub_office` = 'Lady Assistant Steward' THEN 6 WHEN `sub_office` = 'Chaplain' THEN 7 WHEN `sub_office` = 'Treasurer' THEN 8 WHEN `sub_office` = 'Building Treasurer' THEN 9 WHEN `sub_office` = 'Secretary' THEN 10 WHEN `sub_office` = 'Gate Keeper' THEN 11 WHEN `sub_office` = 'Flora' THEN 12 WHEN `sub_office` = 'Pomona' THEN 13 WHEN `sub_office` = 'Ceres' THEN 14 WHEN `sub_office` = 'Executive Committee' THEN 15 WHEN `sub_office` = 'Pianist' THEN 16 WHEN `sub_office` = 'Leadership' THEN 17 WHEN `sub_office` = 'Membership' THEN 18 WHEN `sub_office` = 'Legislative' THEN 19 WHEN `sub_office` = 'Family Activities' THEN 20 WHEN `sub_office` = 'Community Service' THEN 21 WHEN `sub_office` = 'Fun Committee' THEN 22 ELSE 23 END) as sort FROM `MembersTable` WHERE sub_name='$sub_name' ORDER BY sort ASC"; // You can just use this, if thesse are all or most of the values in the table ... // $sql = "SELECT * FROM `MembersTable` WHERE sub_name='$sub_name'"; $result = mysql_query( $sql ) or die( mysql_error() ); $html = ''; while ( $obj = mysql_fetch_object( $result ) ) { $html .= <<<ENDHTML <tr> <td>$obj->sub_office</td> <td>$obj->fname $obj->lname</td> ENDHTML; if ( $session || in_array( $obj->sub_office, $officers ) ) { $html .=<<<ENDHTML <td>$obj->homephone / $obj->cellphone</td> <td>$obj->email</td> <td>$obj->address, $obj->city, $obj->state $obj->zip</td> <td>$obj->sub_name</td> ENDHTML; } $html .= " <\tr>\n"; } $title = "<title>Officers of the $sub_name Subordinate Grange</title>"; ?> <?php include("./config/header.php"); ?> </head> <body> <table width="85%" border="1" class="main"> <tbody> <tr> <td colspan="6"><h2>Officers of <? echo "$sub_name"; ?> Subordinate Grange</h2></td> </tr> <tr> <td><b>Office</b></td> <td><b>Officer</b></td> <td><b>Home / Cell Phone #</b></td> <td><b>Email</b></td> <td><b>Address</b></td> <td><b>Subordinate Grange</b></td> </tr> <?php print $html; ?> <tr> <td colspan="6"><!-- C. FOOTER AREA --> <div class="footer"> <?php include ('./config/footerinfo.php'); ?> </div></td> </tr> </tbody> </table> </body> </html>
I added the SELECT CASE so I could order the offices in a set order.
I do have the 'sub_name' sent from a form currently, but I don't want to switch it to the POST method. I want to keep it so I can make a link and have it go directly to a certain one, therefore I believe it should stay as GET.
Thanks for all your help so far.
There are alot of people smarter than me, BUT at least I try to be of some help. Of coarse I'm not perfect, I need help too.
•
•
Join Date: Aug 2008
Posts: 381
Reputation:
Solved Threads: 33
I was laying there in bed trying to go to sleep and realized I had not added the contingency for empty values or empty table cells ...
Try this
Hope this works for you.
Out of curiosity, what are you doing with these lines in the SELECT statement?
...
Try this
PHP Syntax (Toggle Plain Text)
$html = ''; while ( $obj = mysql_fetch_object( $result ) ) { $display = ( $session || in_array( $obj->sub_office, $officers ) ? TRUE : FALSE; $homephone = ( $display && $obj->homephone ) ? $obj->homephone : ' '; $cellphone = ( $display && $obj->cellphone ) ? $obj->cellphone : ' '; $email = ( $display && $obj->email ) ? $obj->email : ' '; $address = ( $display && $obj->address ) ? $obj->address : ' '; $city = ( $display && $obj->city ) ? $obj->city : ' '; $state = ( $display && $obj->state ) ? $obj->state : ' '; $zip = ( $display && $obj->zip ) ? $obj->zip : ' '; $sub_name = ( $display && $obj->sub_name ) ? $obj->sub_name : ' '; $html .= <<<ENDHTML <tr> <td>$obj->sub_office</td> <td>$obj->fname $obj->lname</td> <td>$homephone / $cellphone</td> <td>$email</td> <td>$address, $city, $state $zip</td> <td>$sub_name</td> <\tr> ENDHTML; }
Out of curiosity, what are you doing with these lines in the SELECT statement?
PHP Syntax (Toggle Plain Text)
(SELECT CASE WHEN `sub_office` = 'Master - President' THEN 1
...
•
•
Join Date: Jun 2008
Posts: 62
Reputation:
Solved Threads: 3
Ok, First off the table looks better, but for some reason I'm getting < r> tags at the end of each row. These are place before the table. I don't understand where they are coming from.
The
lines are to sort the results by a list I set. I don't want the rows sorted alphabetically. I want them according to office, eg the most important office (president) office to the lesser important (the committees).
Thanks Again for you wonderful help.
The
PHP Syntax (Toggle Plain Text)
(SELECT CASE WHEN `sub_office` = 'Master - President' THEN 1
lines are to sort the results by a list I set. I don't want the rows sorted alphabetically. I want them according to office, eg the most important office (president) office to the lesser important (the committees).
Thanks Again for you wonderful help.
There are alot of people smarter than me, BUT at least I try to be of some help. Of coarse I'm not perfect, I need help too.
•
•
Join Date: Aug 2008
Posts: 381
Reputation:
Solved Threads: 33
•
•
•
•
I'm getting < r> tags at the end of each row. These are place before the table. I don't understand where they are coming from
Could they be coming from one of the include files?
Could they be coming from some copy-paste-replacement you made and left a telltale < r> (say from <tr> or <br>)?
Just guessing
And you're welcome about the help :-)
•
•
Join Date: Jun 2008
Posts: 62
Reputation:
Solved Threads: 3
Hi again. I just found where they were coming from. you had typed <\tr> when it should have been </tr>. Once I changed that it made everything show, if I dare say, perfectly. By the way I knew the include files were fine.
Thanks Alot!
Thanks Alot!
There are alot of people smarter than me, BUT at least I try to be of some help. Of coarse I'm not perfect, I need help too.
![]() |
Other Threads in the PHP Forum
- Previous Thread: creating a search form with multiple options, like the search form used on this site?
- Next Thread: prob installing .... help is needed
| Thread Tools | Search this Thread |
apache api array beginner binary body broken buttons cakephp checkbox class cms code cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions global google href htaccess html image include insert ip javascript joomla limit link list login mail mediawiki menu mlm msqli_multi_query multiple mycodeisbad mysql number oop parameter paypal pdf php phpincludeissue problem query radio random recourse recursion regex remote script search seo server sessions sms source sp space speed sql static subdomain syntax system table tag tutorial update upload url validator variable vbulletin video web webdesign white wordpress xml youtube





