php 串联问题
Issue with php concatenation
我收到以下行的错误:
$get = mysql_fetch_assoc( $result );
$id = $_REQUEST['id'];
echo '<form action="invoices.php?id=$id" method="POST">';
echo '<label>Invoice ID: </label>'. $id. '<br>';
echo '<label>User ID: </label>'. $get['customer_id']. '<br>';
echo '<label>Set Status: </label> <select name="status" id="status">
<option value="Unpaid"'.**if($get[/'status/'] == "Unpaid"**){ echo " selected";}.'>Unpaid</option>
<option value="Paid"'.**if($get[/'status/'] == "Paid"**){ echo " selected";}.'>Paid</option>
<option value="Cancelled"' **.if($get[/'status/'] == "Cancelled"**){ echo " selected";}.'>Cancelled</option>
</select>';
它显示的错误是意外的 If 语句在第 xx 行
问题在于 php 连接两个字符串。谁能帮我更正 if 语句?
这个怎么样?
$get = mysql_fetch_assoc( $result );
$id = $_REQUEST['id'];
echo '<form action="invoices.php?id=' . $id . '" method="POST">';
echo '<label>Invoice ID: </label>'. $id. '<br>';
echo '<label>User ID: </label>'. $get['customer_id']. '<br>';
echo '<label>Set Status: </label> <select name="status" id="status">
<option value="Unpaid"'; if($get['status'] == "Unpaid"){ echo "selected"; } echo '>Unpaid</option>
<option value="Paid"'; if($get['status'] == "Paid"){ echo "selected"; } echo '>Paid</option>
<option value="Cancelled"'; if($get['status'] == "Cancelled"){ echo " selected";} echo '>Cancelled</option>
</select>';
实际上并没有加入字符串,但这会对您有所帮助。
我更喜欢这种格式:
echo '<form action="invoices.php?id=' . $id . '" method="POST">';
echo '<label>Invoice ID: </label>'. $id. '<br>';
echo '<label>User ID: </label>'. $get['customer_id']. '<br>';
echo '<label>Set Status: </label>
<select name="status" id="status">
<option value="Unpaid"' . ($get['status'] == 'Unpaid' ? ' selected' : '') . '>Unpaid</option>
<option value="Paid"' . ($get['status'] == 'Paid' ? ' selected' : '') . '>Paid</option>
<option value="Cancelled"' . ($get['status'] == 'Cancelled' ? ' selected' : '') . '>Cancelled</option>
</select>';
我收到以下行的错误:
$get = mysql_fetch_assoc( $result );
$id = $_REQUEST['id'];
echo '<form action="invoices.php?id=$id" method="POST">';
echo '<label>Invoice ID: </label>'. $id. '<br>';
echo '<label>User ID: </label>'. $get['customer_id']. '<br>';
echo '<label>Set Status: </label> <select name="status" id="status">
<option value="Unpaid"'.**if($get[/'status/'] == "Unpaid"**){ echo " selected";}.'>Unpaid</option>
<option value="Paid"'.**if($get[/'status/'] == "Paid"**){ echo " selected";}.'>Paid</option>
<option value="Cancelled"' **.if($get[/'status/'] == "Cancelled"**){ echo " selected";}.'>Cancelled</option>
</select>';
它显示的错误是意外的 If 语句在第 xx 行
问题在于 php 连接两个字符串。谁能帮我更正 if 语句?
这个怎么样?
$get = mysql_fetch_assoc( $result );
$id = $_REQUEST['id'];
echo '<form action="invoices.php?id=' . $id . '" method="POST">';
echo '<label>Invoice ID: </label>'. $id. '<br>';
echo '<label>User ID: </label>'. $get['customer_id']. '<br>';
echo '<label>Set Status: </label> <select name="status" id="status">
<option value="Unpaid"'; if($get['status'] == "Unpaid"){ echo "selected"; } echo '>Unpaid</option>
<option value="Paid"'; if($get['status'] == "Paid"){ echo "selected"; } echo '>Paid</option>
<option value="Cancelled"'; if($get['status'] == "Cancelled"){ echo " selected";} echo '>Cancelled</option>
</select>';
实际上并没有加入字符串,但这会对您有所帮助。
我更喜欢这种格式:
echo '<form action="invoices.php?id=' . $id . '" method="POST">';
echo '<label>Invoice ID: </label>'. $id. '<br>';
echo '<label>User ID: </label>'. $get['customer_id']. '<br>';
echo '<label>Set Status: </label>
<select name="status" id="status">
<option value="Unpaid"' . ($get['status'] == 'Unpaid' ? ' selected' : '') . '>Unpaid</option>
<option value="Paid"' . ($get['status'] == 'Paid' ? ' selected' : '') . '>Paid</option>
<option value="Cancelled"' . ($get['status'] == 'Cancelled' ? ' selected' : '') . '>Cancelled</option>
</select>';