putting in there is a password-protected members directory. I've got
the authentication working like a charm, and for the most part, the
directory listings work, but there's one VERY annoying problem: I'm
having a hard time trying to figure out just how to get the correct
kids to show up in the listings with the correct parents.
Right now, each page ("...members.php?startswith=X", where X is the
letter that each family's name starts with if it matches the
"startswith" clause) is displaying with the kids belonging to ALL the
families on that page showing up under the FIRST entry for that page
and none at all showing up for the other families listed on that page,
and that's obviously not what I want.
Here's the code I have so far:
<code>
$db = mysql_connect("localhost", "root", "") or die("Couldn't connect
to the database.");
mysql_select_db("tatesbrook") or die("Couldn't select the database");
$result1 = mysql_query("select * from heads_of_household where
last_name like '$startswith%' order by last_name") or die("Couldn't
run query #1.");
$num1 = @mysql_result($result1, -1);
$result2 = mysql_query("select * from children, heads_of_household
where ((children.household_id = heads_of_household.household_id) and
(heads_of_household.last_name like '$startswith%')) order by name") or
die("Couldn't run query #2.");
$num2 = @mysql_result($result2, -1);
$rowsreturned = ($row = mysql_num_rows($result1));
$kidsreturned = ($row = mysql_num_rows($result2));
if (!$rowsreturned) { ?>
<div align="center"><table width="620"><tr><td class="calrow1"><b><div
align="center">
Sorry -- we don't have any members whose last name starts with <?php
echo($startswith); ?>.
</div></b></td></tr></table></div>
<?php
} // end of checking for no rows returned
else
{
while ($row = mysql_fetch_array($result1)) {
?><div align="center"><table width="620"><tr>
<td class="calrow1"><b>
<?php
echo ($row["last_name"].", ");
if ($row["male_hoh_fname"]) {
if ($row["male_hoh_email"]) { ?>
<a class="membermail" href=""> echo($row["male_hoh_email"]); ?>">
<?php } // end of check for whether the husband has an E-mail address
echo ($row["male_hoh_fname"]."</a>");
} // end of check for presence of a male head of household
if (($row["male_hoh_fname"]) && ($row["female_hoh_fname"])) {
echo(" & ");
} // end of determining need of ampersand for husband and wife
if ($row["female_hoh_fname"]) {
if ($row["female_hoh_email"]) { ?>
<a class="membermail" href=""> echo($row["female_hoh_email"]); ?>">
<?php } // end of check for whether the husband has an E-mail address
echo ($row["female_hoh_fname"]."</a>");
} // end of check for presence of a female head of household
?>
</b></td></tr>
<tr><td class="calrow2">
<?php if ($row["address"]) {
echo($row["address"]); ?><br />
<?php } // end of check for an address
if ($row["city"]) {
echo($row["city"].", ".$row["state"]." ".$row["zip"]);
} // end of check for what town they live in
?><br /><br /><?php
if ($row["home_phone"]) { ?>
<b>Home phone: </b><?php echo($row["home_phone"]."<br />");
} // end of check for a home phone number
if ($row["male_hoh_cell"]) { ?>
<b><?php echo($row["male_hoh_fname"]); ?>'s cell
phone: </b><?php echo($row["male_hoh_cell"]."<br />");
} // end of check for the husband's cell phone number
if ($row["female_hoh_cell"]) { ?>
<b><?php echo($row["female_hoh_fname"]); ?>'s cell
phone: </b><?php echo($row["female_hoh_cell"]."<br />");
} // end of check for the wife's cell phone number
if ($row["male_hoh_work_phone"]) { ?>
<b><?php echo($row["male_hoh_fname"]); ?>'s work
phone: </b><?php echo($row["male_hoh_work_phone"]."<br />");
} // end of check for the husband's phone number at work
if ($row["female_hoh_work_phone"]) { ?>
<b><?php echo($row["female_hoh_fname"]); ?>'s work
phone: </b><?php echo($row["female_hoh_work_phone"]."<br />");
} // end of check for the wife's phone number at work
if ($row["male_hoh_work_email"]) {
echo("<b>".$row["male_hoh_fname"]."'s E-mail at work:"); ?></b>
<a class="membermail" <?php
echo("href=""> } // end of check for the husband's E-mail address at work
if ($row["female_hoh_work_email"]) {
echo("<b>".$row["female_hoh_fname"]."'s E-mail at work:"); ?></b>
<a class="membermail" <?php
echo("href=""> } // end of check for the wife's E-mail address at work
?></td></tr><?php
// Kids' contact info listing -- here goes nothing...
if ($kidsreturned) {
?><tr><td class="calrow3"><?php
while ($row = mysql_fetch_array($result2)) {
unset($household_id);
$household_id = $row["heads_of_household.household_id"];
if ($row["children.household_id"] == $household_id) {
if ($row["email"]) { ?>
<a class="kidmail" href="" echo($row["email"]); ?>">
<?php } // end of check to make sure the right kids are with the
right parents
} // end of check for whether a particular kid has an E-mail address
echo ($row["name"]."</a><br />");
} // end of kids' while loop
?></tr></td><?php
} // end of checking for kids, for what it's worth...
?><br /><?php
} // end of while loop
} // end of else statement on "if $kidsreturned"
</code>
Does anyone see anything in the above code that would cause ALL the
kids who should be on that page to show up ONLY under the first parent
entry for that page instead of grouped with the correct parents?
Thanx in advance,
Fred in Lexington, KY
Community email addresses:
Post message: [email protected]
Subscribe: [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
List owner: [EMAIL PROTECTED]
Shortcut URL to this page:
http://groups.yahoo.com/group/php-list
SPONSORED LINKS
| Php mysql | Job postings |
YAHOO! GROUPS LINKS
- Visit your group "php-list" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
