我在 html 选择表单上使用多重选择,目的是在一次销售中插入两个 id。
我收到此错误:
Notice: Array to string conversion in C:\xampp\htdocs\allprojects\projects\Colégios\users\teacher\addscore.php on line 33
insert into cursosprogramas (departamento, codigocurso, diurno, contacto, pos_laboral, contacto2, proc_por) values ('100', '120','Array', '88839', '7', '5353','2')Query failed.
代码:
<select type=text name=diurno[] value="<?php echo $name; ?>" multiple size=2><br>
<?php
$sql = "select * from professore1 where coordenacao='$coordenacao' order by coordenacao;";
for ($i= 0; $i < pg_numrows($res);$i++) {
$name = pg_fetch_result ($res, $i, "name");
$numero = pg_fetch_result ($res, $i, "numero");
echo "<option value = '$numero'>$name</option>";
}
?>
</select>
<?php
$idd=$_SESSION['jpgwapo'];
$id=$_POST['id'];
$grdid=$_POST['grdid'];
$diurno=$_POST['diurno'];
$contacto=$_POST['contacto'];
$pos_laboral=$_POST['pos_laboral'];
$contacto2=$_POST['contacto2'];
$con = @pg_connect ("port=5432 host=localhost dbname=postgres user=postgres password=a");
$sql = "insert into cursosprogramas (departamento, codigocurso, diurno, contacto, pos_laboral, contacto2, proc_por) values ('$id', '$grdid','$diurno',
'$contacto', '$pos_laboral', '$contacto2','$idd')";
$res = @pg_query ($con, $sql);
if ($res == NULL){
echo "Query failed.";
exit (0);
}
?>
到目前为止,我已经尝试遵循一些示例,但我仍然不明白它是如何工作的。
繁花不似锦