Hi
I'm sure some wizard out there might be a bit more of an array wizard than I'm proving to be :-))
The prob ....
I've set up a birthday list - all data is chucked into a mysql db.
The db is set up such, that I've got the main person and his/ her respective kids.
The fields are: christ_name, birthdate, birthmonth, kid1name, kid1date, kid1month, kid2name, kid2date, kid2month, kid3name, kid3date, kid3month ..etc
Right, here comes the problem:
Trying to list them in cronological order, I've taken this approach which seems to cock up:
include('includes/db_connect.php');
$sql = "SELECT christ_name, birthdate, birthmonth, kid1name, kid1date, kid1month, kid2name, kid2date, kid2month, kid3name, kid3date, kid3month, kid4name, kid4date, kid4month FROM birthdays WHERE birthmonth='$thismonth' OR kid1month='$thismonth' OR kid2month='$thismonth' OR kid3month='$thismonth' OR kid4month='$thismonth' GROUP BY birthdate, kid1date, kid2date, kid3date, kid4date ASC";
$result = mysql_query($sql, $conn);
if ($result) {
$number = mysql_num_rows($result);
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
$b_month = $row[2];
$kid1_month = $row[5];
$kid2_month = $row[8];
$kid3_month = $row[11];
$kid4_month = $row[14];
if ($thismonth == $b_month) {
$name = $row[0];
$birthday= "$row[1].$row[2]";
}
if ($thismonth == $kid1_month) {
$name = $row[3];
$birthday= "$row[4].$row[5]";
}
if ($thismonth == $kid2_month) {
$name = $row[6];
$birthday= "$row[7].$row[8]";
}
if ($thismonth == $kid3_month) {
$name = $row[9];
$birthday= "$row[10].$row[11]";
}
if ($thismonth == $kid4_month) {
$name = $row[12];
$birthday= "$row[12].$row[13]";
}
// this is where I tried the arrays
echo $birthday;
echoing $birthday works fine - but not in chronological order!?!
I HAVE tried varying array statements (which I have not included here). Can anyone put me on the right track??
Thx
Kev