Jump to content

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

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.