2uzhan.com
Advertisement
Now Place:2uzhan.com » you searched for ***?

you searched for ***?

PHP @ December 31, 1969   Views:0

Hello

I have a form which has a drop down menu on it. The drop down menu is populated from the field of a table called consultant.
The value I want the form to send is in another field of the table and it is called consultant_id

So my form has a select box like this

<select name="consultant_search">
<option value=$consultant_id>$consultant</option>

This is great as it returns exactly what I want for the SQL statement on the page that actions it.

However I want to say something like

you searched for 'this consultant'
Where this consultant equals the $consultant. But if I say

You searched for '<? echo $_GET['consultant_search']; ?>'

I get $consultant_id

So yes its doing exactly what I'm telling it to.

So what code do I need to add where to get the desired result?

I do hope that makes sense!

--------------Solutions-------------

You just need to build a function that queries your consultants by ID and returns the name. So your call might look like this:

You searched for '<? echo getConsultantName($_GET['consultant_search']); ?>'

And the function might look like:

PHP Code:

function getConsultantName($id)
{
  $name = '';
  $query = 'SELECT CONSULTANT_NAME FROM CONSULTANT_TABLE WHERE CONSULTANT_ID = ' . $id;
  // execute query
  // retrieve row (error check here and make sure the row is available
  // retrieve field data - store it in $name
  return $name;
}  // end function getConsultantName($id) 

Tags:
© 2018 2uzhan.com Contact