2017-01-24 1 views
-1

avilable在庫数のドロップダウンメニューリストを作成したいと思います。これは今まで私が行ったコードですが、まったく動作しません。このエラーが表示されます:PHPを使用したドロップダウンメニューリスト

Parse error: syntax error, unexpected 'basket' (T_STRING), expecting ',' or ';'

<?php 

include("db.php"); 
//create a variable called $pagename which contains the actual name of the page 
$pagename="Product Information"; 

//call in the style sheet called ystylesheet.css to format the page as defined in the style sheet 
echo "<link rel=stylesheet type=text/css href=mystylesheet.css>"; 

//display window title 
echo "<title>".$pagename."</title>"; 
//include head layout 
include ("headfile.html"); 

echo "<p></p>"; 
//display name of the page and some random text 
echo "<h2>".$pagename."</h2>"; 


//retrieve the product id passed from the previous page using the $_GET superglobal variable 
//store the value in a variable called $prodid 
$prodid=$_GET['u_prodid']; 
//echo "<p>Selected product Id: ".$prodid; 

//query the product table to retrieve the record for which the value of the product id 
//matches the product id of the product that was selected by the user 
$prodSQL="select prodId, prodName, prodPicName, 
prodDescrip , prodPrice, prodQuantity from product 
where prodId=".$prodid; 
//execute SQL query 
$exeprodSQL=mysql_query($prodSQL) or die(mysql_error()); 
//create array of records & populate it with result of the execution of the SQL query 

$thearrayprod=mysql_fetch_array($exeprodSQL); 

//display product name in capital letters 

echo "<p><left><b>".strtoupper($thearrayprod['prodName'])."</b></left>"; 
echo "<p><img src=images/".($thearrayprod['prodPicName']).">"; 
echo "<p><left>".($thearrayprod['prodDescrip'])."</left>"; 

echo "<br>"; 
echo "<br>"; 
echo "GBP<left> ".($thearrayprod['prodPrice'])."</left>"; 
echo "<br>"; 
echo "<br>"; 
echo "Number in stock:<left> ".($thearrayprod['prodQuantity'])."</left>"; 

//display form made of one text box and one button for user to enter quantity 
//pass the product id to the next page basket.php as a hidden value 
echo "<form action="basket.php" method=post>"; 
echo "<p><span style="text-align: center";>Enter required Quantity: "; 
echo '<select name="options">'; 
for($i=1; $i<=4; $i++) 
{ 
    echo "<option value=".$i.">".$i."</option>"; 
} 
echo '</select>'; 

echo "<input type=hidden name=h_prodid value=".$prodid.">"; 
echo "<input type=submit value='Add to Basket'>"; 
echo "</span>"; 
echo "</form>"; 

//include head layout 
include("footfile.html"); 
?> 
+0

送信ボタンは 'for()'ループ内にあってはなりません。 – Barmar

+0

ループの後に ''もありません。 – Barmar

+0

あなたは ''と一致するものがなく、

と一致しないものが '
'で、' 'があります。これらはどちらも廃止されており、CSSスタイルを使用する必要があります。 – Barmar

答えて

0

ボタンが<select>タグの外側ではなく、オプションを作成するループ内でなければなら提出します。

echo "<form action='basket.php' method='post'>"; 
echo "<p><span style='text-align: center';>Enter required Quantity: "; 
echo '<select name="options">'; 
for($i=1; $i<=4; $i++) 
{ 
    echo "<option value=".$i.">".$i."</option>"; 
} 
echo '</select>'; 

echo "<input type='hidden' name='h_prodid' value='".$prodid."'>"; 
echo "<input type='submit' value='Add to Basket'>"; 
echo "</span>"; 
echo "</form>"; 

また、古くなった<center>タグの代わりにCSSを使用する必要があります。 <select name="options">文字列の周りに引用符がありませんでした。そして、タグに属性値を引用符で囲む必要があります。

+0

コード全体を表示するために上記のコードを編集しました。エラーがバスケットにあると思います。 –

+0

引用の問題があります。 "echo"

";'または 'echo" "; 'エスケープしない限り、文字列内で同じ引用符を使用することはできません。 – Barmar

関連する問題