Jump to content

Php Select Drop Down Box


ncurran217

Recommended Posts

I have this code and I have finally got the results in a select drop down box, but each row is in a separate drop down box, not it one with multiple ones. Here is my code:

 

<h1>View Log</h1>
<?php
 $timezone = "America/Chicago";
 date_default_timezone_set($timezone);
 $today = date("m/d/Y");
?>
<form method="get" action="getlog.php">
<table width="1500" border="0">
<tr>
 <td>Forte ID:</td>
 <td>
<?php 
$serverName2 = 'SRB-Nick_Desktop\SQLEXPRESS';
$connectionInfo2 = array('Database'=>'cslogs', 'UID'=>'cslogslogin', 'PWD'=>'123456');
$connection2 = sqlsrv_connect($serverName2, $connectionInfo2);


$query2 = ' SELECT ForteID
  FROM Reps';


$result2 = sqlsrv_query($connection2,$query2);


if (!$result2)


{
$message2 = 'ERROR: ' . sqlsrv_errors();
return $message2;
}
else
{ 
$i2 = 0;
while ($i2 < sqlsrv_num_rows($result2))
{
 $meta2 = sqlsrv_fetch($result2, $i2);
 echo '' . $meta2->name . '';
 $i2 = $i2 + 1;
}


while ( $row2 = sqlsrv_fetch_array( $result2, SQLSRV_FETCH_ASSOC ))
{
 $count2 = count($row2);
 $y2 = 0;
 while ($y2 < $count2)
 {
  $c_row2 = current($row2);
  echo '<select name="test" id="test">';
  echo '<option name="Forte_ID" id="Forte_ID" value="' .$c_row2. '";>' .$c_row2.'</option>';  
  next($row2);
  $y2 = $y2 + 1;
 }
  echo '</select>';
}
sqlsrv_free_stmt ($result2);
}
sqlsrv_close( $connection2);
?>


 </td>
</tr>
<tr>
 <td>Start Date:</td>
 <td><input name="start_date" type="date" value="<?php echo $today;?>" autocomplete="off" required="required"></td>
</tr>
<tr>
 <td>End Date:</td>
 <td><input name="end_date" type="date" value="<?php echo $today;?>" autocomplete="off" required="required"></td>
</tr>
</table>
<br>
<input type="submit" name="getLog" value="Get Log"><br><br>
<input type="button" value="Back to Form" onclick="window.location.href='index.php';"> <br>
</form>

 

Let me know if a picture of what it looks like would help! Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/272224-php-select-drop-down-box/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.