Filter recordset using a Session Variable

I’m not sure if this post should be here or in the SQL area…

I have a PHP registration form that sends data to a database and also sends two emails, one to the administrators and one to the person registering.

When a person registers they select a member organisation from a drop down which submits the record number of that organisation to the database.

When the admins recieve the email it shows the record number and not the unit name.

<?php echo((isset($_POST["unit"]))?$_POST["unit"]:"") ?>

How would I get the unit name to show instead?

I have tried linking the unit name

<?php echo $row_unit['unit_name']?>

But this just displays the first unit name in the database.

So how do I show the unit name that corresponds to the unit number submitted in the form?

Would it be something like;

<?php if $row_unit['unit_name'] = ((isset($_POST["unit"]))?$_POST["unit"]:"")
echo $row_unit['unit_name'] ?>

Thanks in advance!

You have to query your database for unit name. Use WHERE operator to get certain row

OK, something like this…

SELECT units.unit_name
FROM units
WHERE units.unit_id

But how do I do

WHERE units.unit_id = Session Variable?

or whatever is required to show the name based on the session variable sent from the submitted form?

Like any other variable.
Ever did in your first PHP script something like "Hello ".$name? Same here.

And you are using wrong terminology. There are no session variables in your code. Only request ones.

Or yes, you can have unit name instead of id.
just put unit name into “value” parameter instead of id in your form generating script