Jump to content

Recommended Posts

Hello,

 

I have a quick question...

 

I have a php script that I'd like to create a couple dropdown boxes that will plug a value into a query.  I would also like to include a radio button that would also change the query.  Here is a sample of my code (right now it just shows results in a table).  I'd like to keep it the same but for example, I'd like to create a dropdown with a list of facilities that would change the value of PSC_Assoc__Group_s_Affected.  Or perhaps add a radio button that would insert a does not equal somewhere in the statement.  It seems easy enough, I just don't know where to start and how to get the dropdown values to insert into the query.  Here's my code:

 

<?php


$dsn = "OPASRPT";

$conn = odbc_connect($dsn, '', '');


$today = date("Y-m-d");
$tomorrow = date("Y-m-d",mktime(0,0,0,date("m"), date("d")+1, date("Y")));



$query = "SELECT Account_s__Affected, Assignee_Group, Assignee_Name__, Assignee_Phone, Change_Type, Change_Id, End_Date_and_Time,  Short_Description, Start_Date_and_Time, Status, Risk_Level FROM Change_Management WHERE (PSC_Assoc__Group_s__Affected LIKE '%SC-FSS-Arroyo%') AND (Start_Date_and_Time>={ts '$today 00:00:00'} AND Start_Date_and_Time<={ts '$tomorrow 00:00:00'})";

$result = odbc_exec($conn, $query) or die("Query failed, could not connect to table.  Are you sure it exists?");


$results_array = array();
while(odbc_fetch_row($result))
{
  $results_array[] = array(  //ARRAY NEEDED FOR STINKIN' IF/ELSE
  'actaffected' => odbc_result($result, 1),
  'assigneegrp' => odbc_result($result, 2),
  'assigneename' => odbc_result($result, 3),
  'assigneephone' => odbc_result($result, 4),
  'changetype' => odbc_result($result, 5),
  'changeid' => odbc_result($result, 6),
  'enddate' => odbc_result($result, 7),
  'shortdes' => odbc_result($result, ,
  'startdate' => odbc_result($result, 9),
  'status' => odbc_result($result, 10),
  'risklvl' => odbc_result($result, 11)
  );
  
  }

if (empty($results_array))
{
  exit('<p align=center><font face=Tahoma size=2><br><b>There are no planned changes for this day.</b></p>');
}

//IF RESULTS, PRINT TABLE
else
{

?>


<table style="border-collapse: collapse" border=".5em" bordercolor="#000000" cellspacing="1" cellpadding="0">
        <tr>
            <td><font face="Tahoma" size="1"><b>Change ID</td>
            <td><font face="Tahoma" size="1"><b>Start Date and Time</td>
            <td><font face="Tahoma" size="1"><b>Assignee Name</td>
            <td><font face="Tahoma" size="1"><b>Assignee Phone</td>
            <td><font face="Tahoma" size="1"><b>Assignee Group</td>
  <td><font face="Tahoma" size="1"><b>Change Type</td>
  <td><font face="Tahoma" size="1"><b>Risk Level</td>
  <td><font face="Tahoma" size="1"><b>Status</td>
  <td><font face="Tahoma" size="1"><b>End Date and Time</td>
  <td><font face="Tahoma" size="1"><b>Short Description</td>
        </tr>

<?php

//PRINTING THE RESULT

foreach($results_array AS $this_row)
  {

  echo"<tr><td width=80><font face=Tahoma size=1>{$this_row['changeid']}</td><td width=63><font face=Tahoma size=1>{$this_row['startdate']}</td><td width=90><font face=Tahoma size=1>{$this_row['assigneename']}</td><td width=90><font face=Tahoma size=1>{$this_row['assigneephone']}</td><td width=90><font face=Tahoma size=1>{$this_row['assigneegrp']}</td><td width=90><font face=Tahoma size=1>{$this_row['changetype']}</td><td width=70><font face=Tahoma size=1>{$this_row['risklvl']}</td><td width=80><font face=Tahoma size=1>{$this_row['status']}</td><td width=65><font face=Tahoma size=1>{$this_row['enddate']}</td><td width=200><font face=Tahoma size=1>{$this_row['shortdes']}</td></tr>";
  
  
}


}


//CLOSING THE CONNECTION


odbc_close($conn);
?>
</table>

 

Any help would be appriciated.  Thanks!

Link to comment
https://forums.phpfreaks.com/topic/55587-help-with-a-simple-dropdown-array/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.