que je veux faire sous forme d'édition, la valeur déjà utilisateur est sélectionné des moyens que je veux afficher sous forme d'édition de la valeur de la case est cochée, alors je suis d'essayer comme çaComment faire la valeur de case cochée dans le tableau
<?php
include("dbconfig.php");
$sql = "SELECT * FROM residential_propertytype WHERE status !='1'";
$result = mysql_query($sql);
while($pr_type = mysql_fetch_array($result))
{
$propty[] = $pr_type;
}
echo "<pre>";
var_dump($propty);
echo "</pre>";
foreach($propty as $res)
{
$checked = in_array($res['id'], 5) ? 'checked' : '';
?>
<input type="checkbox" value="<?php echo $res['id']?>" <?php echo $checked; ?>><?php echo $res['propertyName']?>
<?php
}
?>
Voir ci-dessous var_dump (de propty de $) Je reçois réponse comme ça
array(10) {
[0]=>
array(8) {
[0]=>
string(1) "1"
["id"]=>
string(1) "1"
[1]=>
string(9) "Apartment"
["propertyName"]=>
string(9) "Apartment"
[2]=>
string(0) ""
["reg_date"]=>
string(0) ""
[3]=>
string(1) "0"
["status"]=>
string(1) "0"
}
[1]=>
array(8) {
[0]=>
string(1) "2"
["id"]=>
string(1) "2"
[1]=>
string(9) "Villament"
["propertyName"]=>
string(9) "Villament"
[2]=>
string(0) ""
["reg_date"]=>
string(0) ""
[3]=>
string(1) "0"
["status"]=>
string(1) "0"
}
[2]=>
array(8) {
[0]=>
string(1) "3"
["id"]=>
string(1) "3"
[1]=>
string(16) "Individual House"
["propertyName"]=>
string(16) "Individual House"
[2]=>
string(0) ""
["reg_date"]=>
string(0) ""
[3]=>
string(1) "0"
["status"]=>
string(1) "0"
}
[3]=>
array(8) {
[0]=>
string(1) "4"
["id"]=>
string(1) "4"
[1]=>
string(9) "Row House"
["propertyName"]=>
string(9) "Row House"
[2]=>
string(0) ""
["reg_date"]=>
string(0) ""
[3]=>
string(1) "0"
["status"]=>
string(1) "0"
}
[4]=>
array(8) {
[0]=>
string(1) "5"
["id"]=>
string(1) "5"
[1]=>
string(5) "Villa"
["propertyName"]=>
string(5) "Villa"
[2]=>
string(0) ""
["reg_date"]=>
string(0) ""
[3]=>
string(1) "0"
["status"]=>
string(1) "0"
}
[5]=>
array(8) {
[0]=>
string(1) "6"
["id"]=>
string(1) "6"
[1]=>
string(4) "Plot"
["propertyName"]=>
string(4) "Plot"
[2]=>
string(0) ""
["reg_date"]=>
string(0) ""
[3]=>
string(1) "0"
["status"]=>
string(1) "0"
}
[6]=>
array(8) {
[0]=>
string(1) "7"
["id"]=>
string(1) "7"
[1]=>
string(13) "Builder Floor"
["propertyName"]=>
string(13) "Builder Floor"
[2]=>
string(0) ""
["reg_date"]=>
string(0) ""
[3]=>
string(1) "0"
["status"]=>
string(1) "0"
}
[7]=>
array(8) {
[0]=>
string(1) "8"
["id"]=>
string(1) "8"
[1]=>
string(9) "Penthouse"
["propertyName"]=>
string(9) "Penthouse"
[2]=>
string(0) ""
["reg_date"]=>
string(0) ""
[3]=>
string(1) "0"
["status"]=>
string(1) "0"
}
[8]=>
array(8) {
[0]=>
string(1) "9"
["id"]=>
string(1) "9"
[1]=>
string(10) "Farm House"
["propertyName"]=>
string(10) "Farm House"
[2]=>
string(0) ""
["reg_date"]=>
string(0) ""
[3]=>
string(1) "0"
["status"]=>
string(1) "0"
}
[9]=>
array(8) {
[0]=>
string(2) "10"
["id"]=>
string(2) "10"
[1]=>
string(16) "Studio Apartment"
["propertyName"]=>
string(16) "Studio Apartment"
[2]=>
string(0) ""
["reg_date"]=>
string(0) ""
[3]=>
string(1) "0"
["status"]=>
string(1) "0"
}
}
en allant rendre la valeur de case cochée J'obtiens l'erreur Avertissement: in_array() attend le paramètre 2 soit tableau, entier donné h omment résoudre ce problème
Vérifiez http://php.net/manual/fr/function.in-array.php. Le deuxième paramètre devrait être le tableau. –
L'avertissement vous indique comment résoudre ce problème. Vous devez passer un 'array', mais vous passez' 5' qui est un entier. – BizzyBob
comment puis-je passer s'il vous plaît mettre à jour votre réponse –