Welcome Guest, Not a member yet? Register   Sign In
If data exists in the field print, else don't
#32

[eluser]slowgary[/eluser]
It probably would make more sense to just have a 'participants' table and use a type=ENUM('guardian', 'student'). It might also make querying more difficult. I can't picture how you'd do what your currently doing with a few joins unless you use multiple queries (yuck).

Also, I have to disagree with you Jedd on your recommendation of removing prefixes. I've seen your arguments before on prefixes and singular names, and while it does make a lot of sense to me to see code like this:
Code:
student.id
guardian.phone
as opposed to this:
Code:
students.student_id
guardians.guardian_phone
I still vote for the latter only because of the annoyance of having a bunch of "AS guardian_phone" clauses in my join queries. Especially in this scenario where there will be a lot of joined fields that will have the same name.

As far as having a student_phones table, you really only need it if the relationship between students and phones is one to many (or if you actually care about storing more than 1 phone per person). You could keep the phones table and just store the phone_id in the students table. This would still allow people to share phone numbers.

Also zebake, your view code is just going to need some logic to test for these scenarios. I'm curious though, will you not be displaying the student's actual address? If not, how do you know which address is the student's permanent one (in the event that there are multiple guardians)? Would you even store additional addresses? Like if a student lived with one parent but you store the other parent for an emergency contact, would you also need that second parent's address? Basically, I don't see in your examples an easy way to determine where to send the student's report card.

I think the easiest way to do the view is to use a few "temp" variables to store the previous loop's value, then test against it in the loop and branch your echos with a few if/elses.


Messages In This Thread
If data exists in the field print, else don't - by El Forum - 07-01-2009, 05:00 PM
If data exists in the field print, else don't - by El Forum - 07-01-2009, 05:28 PM
If data exists in the field print, else don't - by El Forum - 07-01-2009, 06:15 PM
If data exists in the field print, else don't - by El Forum - 07-01-2009, 06:24 PM
If data exists in the field print, else don't - by El Forum - 07-01-2009, 06:36 PM
If data exists in the field print, else don't - by El Forum - 07-01-2009, 06:52 PM
If data exists in the field print, else don't - by El Forum - 07-01-2009, 09:00 PM
If data exists in the field print, else don't - by El Forum - 07-01-2009, 09:12 PM
If data exists in the field print, else don't - by El Forum - 07-01-2009, 09:13 PM
If data exists in the field print, else don't - by El Forum - 07-01-2009, 09:50 PM
If data exists in the field print, else don't - by El Forum - 07-02-2009, 03:20 AM
If data exists in the field print, else don't - by El Forum - 07-02-2009, 03:29 AM
If data exists in the field print, else don't - by El Forum - 07-02-2009, 03:40 AM
If data exists in the field print, else don't - by El Forum - 07-02-2009, 05:51 AM
If data exists in the field print, else don't - by El Forum - 07-02-2009, 08:02 AM
If data exists in the field print, else don't - by El Forum - 07-02-2009, 08:16 AM
If data exists in the field print, else don't - by El Forum - 07-02-2009, 08:22 AM
If data exists in the field print, else don't - by El Forum - 07-02-2009, 08:31 AM
If data exists in the field print, else don't - by El Forum - 07-02-2009, 08:34 AM
If data exists in the field print, else don't - by El Forum - 07-02-2009, 09:16 AM
If data exists in the field print, else don't - by El Forum - 07-02-2009, 01:07 PM
If data exists in the field print, else don't - by El Forum - 07-02-2009, 01:22 PM
If data exists in the field print, else don't - by El Forum - 07-02-2009, 01:23 PM
If data exists in the field print, else don't - by El Forum - 07-02-2009, 03:29 PM
If data exists in the field print, else don't - by El Forum - 07-02-2009, 03:37 PM
If data exists in the field print, else don't - by El Forum - 07-02-2009, 05:09 PM
If data exists in the field print, else don't - by El Forum - 07-03-2009, 12:44 AM
If data exists in the field print, else don't - by El Forum - 07-03-2009, 12:55 AM
If data exists in the field print, else don't - by El Forum - 07-03-2009, 03:58 AM
If data exists in the field print, else don't - by El Forum - 07-03-2009, 08:01 AM
If data exists in the field print, else don't - by El Forum - 07-03-2009, 08:16 AM
If data exists in the field print, else don't - by El Forum - 07-03-2009, 09:00 AM
If data exists in the field print, else don't - by El Forum - 07-03-2009, 09:33 AM
If data exists in the field print, else don't - by El Forum - 07-03-2009, 09:49 AM
If data exists in the field print, else don't - by El Forum - 07-03-2009, 10:01 AM
If data exists in the field print, else don't - by El Forum - 07-03-2009, 10:08 AM
If data exists in the field print, else don't - by El Forum - 07-03-2009, 11:01 AM
If data exists in the field print, else don't - by El Forum - 07-03-2009, 11:08 AM
If data exists in the field print, else don't - by El Forum - 07-03-2009, 11:38 AM
If data exists in the field print, else don't - by El Forum - 07-03-2009, 11:53 AM



Theme © iAndrew 2016 - Forum software by © MyBB