PHP组合框未显示在HTML表中
我在PHP中创建了一个html表,其中包含一个组合框,用于检索mysql数据库表的值 这是我的代码:PHP组合框未显示在HTML表中,php,html,combobox,html-table,Php,Html,Combobox,Html Table,我在PHP中创建了一个html表,其中包含一个组合框,用于检索mysql数据库表的值 这是我的代码: <?php include_once 'indeling/header.php'; print '<a href="overzicht_notass.php" class="button">Overzicht nota\'s</a> <br /><br />'; $sql = " SELECT notas.id AS no
<?php
include_once 'indeling/header.php';
print '<a href="overzicht_notass.php" class="button">Overzicht nota\'s</a> <br /><br />';
$sql = "
SELECT
notas.id AS notaid
, notas.klantid AS klantid
, notas.bedrag AS bedrag
, notas.datum AS datum
, contacten.bedrijf AS bedrijf
, contacten.adres AS adres
, contacten.woonplaats AS woonplaats
FROM
notas
LEFT JOIN contacten
ON (notas.klantid = contacten.id);
";
function bedrijven($mysqli) {
$sqlbedrijven = "
SELECT
id
, bedrijf
, adres
, woonplaats
FROM
contacten
ORDER BY bedrijf ASC
";
$resultbedrijven = $mysqli->query($sqlbedrijven);
if (!$resultbedrijven) {
echo "something went wrong: (" . $mysqli->error .")";
}
echo "<select name = klantid>\n";
while ($row = $resultbedrijven->fetch_assoc()) {
echo <<<opt
<option value="{$row['id']}"> {$row['bedrijf']} - {$row['adres']} - {$row['woonplaats']} </option>
opt;
}
echo "</select>\n";
}
$result = $mysqli->query($sql);
if (!$result) {
echo "Oeps hier gaat iets fout: (" . $mysqli->error .")";
}
else {
printf("Er zijn momenteel %d nota's.<br />", $result->num_rows);
echo "
<table>
<tr>
<th>notanummer.</th>
<th>bedrijf</th>
<th>bedrag</th>
<th>datum</th>
<th>bewerken</th>
</tr>
";
while ($row = $result->fetch_assoc()) {
echo '<tr> <form action="overzicht_relaties_bewerken.php" method="post">
<td> <input type="text" class="short" name="notaid" value="' . $row['notaid'] . '"></td>
<td> ' . bedrijven($mysqli) . ' </td>
<td> <input type="text" name="bedrag" value="' . $row['bedrag'] . '"></td>
<td> <input type="date" name="datum" value="' . $row['datum'] . '"></td>
<td> <input type="submit" name="update" value="aanpassen" class="button">' . '<br />
<input type="submit" name="delete" value="verwijderen" class="button"' . '"></td>
</tr></form>
';
}
echo "</table>";
}
?>
我不擅长php,但我认为您的选择
标记不在表中
!请参见如何在html中执行此操作:
<table>
<tr>
<th>notanummer.</th>
<th>bedrijf</th>
<th>bedrag</th>
<th>datum</th>
<th>bewerken</th>
</tr>
<tr>
<td colspan='5'>
<select name = klantid>
<option value="37"> afsdf - fasdf12 - Klarenbeek - (Gelderland) </option>
<option value="36"> afsdf - fasdf12 - Klarenbeek - (Gelderland) </option>
<option value="38"> afsdf2 - fdas - Klarenbeek </option>
</select>
</td>
</tr>
<tr> <form action="overzicht_relaties_bewerken.php" method="post">
<td> <input type="text" class="short" name="notaid" value="2"></td>
<td> </td>
<td> <input type="text" name="bedrag" value="125.50"></td>
<td> <input type="date" name="datum" value="2013-06-04"></td>
不是努默。
贝德里杰夫
抹布
资料
比沃肯
afsdf-fasdf12-Klarenbeek-(格尔德兰)
afsdf-fasdf12-Klarenbeek-(格尔德兰)
afsdf2-fdas-Klarenbeek
因此,将您的php代码更改为:
echo "<select name = klantid>\n";
while ($row = $resultbedrijven->fetch_assoc()) {
echo <<<opt
<option value="{$row['id']}"> {$row['bedrijf']} - {$row['adres']} - {$row['woonplaats']} </option>
opt;
}
echo "</select>\n";
echo“\n”;
而($row=$resultbedrijven->fetch_assoc()){
echo fetch_assoc()){
echo Thank you Seyed您的解决方案不起作用。html部分是正确的,但我没有在PHP中这样做。我所做的是:我将函数的内容复制到PHP表中。这就解决了问题。谢谢您的帮助
<table>
<tr>
<th>notanummer.</th>
<th>bedrijf</th>
<th>bedrag</th>
<th>datum</th>
<th>bewerken</th>
</tr>
<tr>
<td colspan='5'>
<select name = klantid>
<option value="37"> afsdf - fasdf12 - Klarenbeek - (Gelderland) </option>
<option value="36"> afsdf - fasdf12 - Klarenbeek - (Gelderland) </option>
<option value="38"> afsdf2 - fdas - Klarenbeek </option>
</select>
</td>
</tr>
<tr> <form action="overzicht_relaties_bewerken.php" method="post">
<td> <input type="text" class="short" name="notaid" value="2"></td>
<td> </td>
<td> <input type="text" name="bedrag" value="125.50"></td>
<td> <input type="date" name="datum" value="2013-06-04"></td>
echo "<select name = klantid>\n";
while ($row = $resultbedrijven->fetch_assoc()) {
echo <<<opt
<option value="{$row['id']}"> {$row['bedrijf']} - {$row['adres']} - {$row['woonplaats']} </option>
opt;
}
echo "</select>\n";
echo "<tr><td colspan='5'><select name = klantid>\n";
while ($row = $resultbedrijven->fetch_assoc()) {
echo <<<opt
<option value="{$row['id']}"> {$row['bedrijf']} - {$row['adres']} - {$row['woonplaats']} </option>
opt;
}
echo "</select></td></tr>\n";