创建一个下拉菜单并从数据库中获取项目,我的代码是错误的我总是得到空的空格

I am creating a drop down menu to get items from database.
Following is my code:

<select name="select" class="ed" id="partname">
<option id="0">--Select Part Name/Description--</option>
<?php 

 include('connect.php');    

 $getallparts = mysql_query("SELECT * FROM parts");
 while($viewallparts = mysql_fetch_array($getallparts)){
 ?>

<option id="<?php echo $viewallparts['parts_id']; ?>"><?php echo$getallparts['part_description'] ?></option>
<?php } ?>

</select>

What's wrong with my code? I always get empty spaces..

As Michael Radionov said there should be a space after echo kindly use

<option id="<?php echo $viewallparts['parts_id']; ?>">
<?php echo    $getallparts['part_description'] ?></option>
<select name="select" class="ed" id="partname">
<option id="0">--Select Part Name/Description--</option>
<?php 

 include('connect.php');    

$getallparts = mysql_query("SELECT * FROM parts");
 while($viewallparts = mysql_fetch_array($getallparts)){
 ?>
<option id="<?php echo $viewallparts['parts_id']; ?>">
<?php echo $getallparts['part_description'] ?>
</option>
<?php } ?>
</select>

I think the problem is in echo statement because logic is correct. your declaration part took error due to missing of semicolon.

I think you'll find mysqli_query takes 2 parameters, parameter 1 is mysqli_connect and the second one is the query.

$con = mysqli_connect("**" , "**" , "**" , "**");
$q = mysqli_query($con , $query);

Replace <?php echo$getallparts['part_description'] ?>

with <?php echo $viewallparts['part_description'] ?>.

Code was wrong (space after echo was missing) and you were echoing from the wrong variable $getallparts.