I actually try to put some checked checkbox in foreach but i have a problem with it. Because i think foreach don't get a array and it return this message: Warning: Invalid argument supplied for foreach()
There is my main page with checkbox:
<form class="form" action="resultat.php" method="POST">
<?php require_once 'script.php';
$num=$_GET["flux1"];
if($num==1){
$url ="http://ift.tt/1pXVAu7";
info($url);
}
elseif ($num==2) {
$url="http://ift.tt/2sdKyYc";
info ($url);
}
elseif($num ==3){
$url='http://ift.tt/2sdKyYc';
info ($url);
}
?>
<input type ="submit" name="valider" value="valider">
</form>
There is my php function to treat rss and put checkbox close to them:
function info($url){
//Load RSS
if ( $flux=simplexml_load_file($url) ) {
$donnee = $flux->channel;
//Read data
foreach( $donnee->item as $valeur ) {
//return data
print('<p>'.date("d/m/Y",strtotime($valeur->pubDate)).' - <a
href="'.$valeur->link.'">'.$valeur->title.'</a>'."\n");
print('<br/>'.$valeur->description.'<input type="checkbox" name='.$valeur-
>title' value='.$valeur->link.>'Selectioner le flux RSS</p>'."\n");
}
} else{
print('Eror');
}
}
and this is my final web page with the rss selected:
<!DOCTYPE html>
<html>
<head>
<title>Resultat</title>
</head>
<body>
<?php
$rss= $_POST['checkbox'];
if(isset($_POST['checkbox'])) {
echo "Voulez vous selectioner les flux suivant ? <br>";
foreach ($name as $flux){
echo $flux."<br />";
}
} // end brace for if(isset
else {
echo "You did not choose a color.";
}
?>
</body>
</html>
I think i must put the checked checkbox in array but i don't realy see how to do that can you please help me ? :)
Aucun commentaire:
Enregistrer un commentaire