?
For example, what about if you want to print an address label with the member name at the beginning of it? You donât want it to come out as youâre storing it, because it looks awful, so you have to write some code to split it by comma and re-order it. If itâs stored as separate fields for firstname and lastname, you can still sort by lastname if you need to, and you can easily output it in the âcorrectâ order.
True, but I still donât understand how you obtain the ID from the members table to put it in the attendance table⌠I know I have to separate the name out and store the ID, but what can I do to get the user ID by search? Is this a matter of using a hidden form input or do I have to use Ajax and JS? If this has already been answered, show me where so I can try to make sense of it.
This line here:
echo "<p>" . $row['id'] . " -+- " . $row['name'] . "</p>";
means that your search is now returning two things, and will display two things in the drop-down list. So instead of the image you showed with âDOE, Johnâ in the drop-down, youâll see 1 -+- DOE, John
in the list. Presumably your code then inserts that into the ânameâ form field.
When you submit the form, your $_POST['member_name']
field will contain 1 -+- DOE, John
. The little code snippet I posted above shows you how to split that into an array of values. In this example, your var_dump()
of that array would show something like
array(2) { [0]=> string(1) "1" [1]=> string(9) "DOE, John" }
So you can see that the member id is now in $ary[0]
, so thatâs what you use to insert into the attendance table.
Normally Iâd use a drop-down as the selection, so youâd have code like
<select name="member_name">
<option value="1">DOE, John</option>
<option value="2">ELLIS, John</option>
<option value="3">LENNON, John</option>
</select>
and when you pick a choice from the drop-down, you would get the value submitted rather than the text (if theyâre different), which would do it easier for you. But youâre not using a drop-down.
Ok. I think I got it working. Now I just need to figure out how to generate the report to show what I need.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.