0

I have an HTML Drop Down List I would like to run two values in it, the reason for this is due to the SQL database I have one value is numeric to link to one section of the SQL and the other is a description to go into a different table in the SQL.

Is this possible to do using POST in the main form and how would I link it to the correct DB in the PHP function.

HTML Code:

<select required name="casetype">
       <option value="">Please Select One </option>
       <option value="49">Hijacking </option>
       <option value="52">Theft </option>
</select>

PHP Code using $_POST:

The topicId is to populate the TopicId field in OSTicket API

'topicId'   =>      '49',

In the notes of the oSTicket API I have the following, the CASE TYPE section is the Name of the drop down list I know I can have a singular description as my above HTML code where I can either call it 49 or Hijacking, but what I would like to do is have it as 49 for the one table and Hijacking for the other table.

$data = array(
    'name'      =>      "****",  
    'email'     =>      '****',  
    'phone'     =>      '****',  
    'subject'   =>      "$casetype - $client - $reg", // Case type description, Testing multiple POST replies to string
    'message'   =>      "
    Case Type:                  $casetype  //Require a description 
    Vehicle Registration:       $reg
    Vehicle Make:                   $make
    Client:                     $name
    Where was it Taken:         $taken
    Reported by:                $name of $client

    $notes",

I have read about separating the two values and exploding the values but how do I tell the PHP side which one to use where?

Trevor Ackermann
  • 166
  • 1
  • 4
  • 16
  • 2
    If you know id - you can find a name, don't you? – u_mulder Jun 19 '17 at 11:59
  • I know the ID 49 is linked to Hijacking in osTicket yes, but when posting to a normal SQL Table and sending a note to osTicket I cannot link the 49 to the Hijacking at all as I need the name Hijacking to be used in the post reply section and the ID is used for Help topic selection – Trevor Ackermann Jun 19 '17 at 12:01
  • 1
    Isnt this what AJAX was created for? – Master Yoda Jun 19 '17 at 12:02
  • @MasterYoda I am not very familiar with AJAX at all – Trevor Ackermann Jun 19 '17 at 12:05
  • @u_mulder I have read that section on the exploding of the value, how will I direct the code in PHP to select the specific value, will it still be as in that example $Colour for the colour and $Model for the Model? In my instance if I call them ID and Desc will it be $ID and $Desc? – Trevor Ackermann Jun 19 '17 at 12:11

0 Answers0