Hi,

Maybe you can help me with the following: I have a list of visitors that want some 
documentation.. I'm displaying a list with a checkbox so i can check the one's that 
received the documentation. So what is must do; it must update a table called 
prospects and set the value of a field called prbrochverst to 1 .
Only problem it doesn't work; can you have a look?


// includes
include("../../conf/config.php");
include("../../conf/functions.php");

// open database connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");

// select database
mysql_select_db($db) or die ("Unable to select database!");

// generate and execute query
$query = "SELECT prospectid, praanhef, prvoorletter, prtussenv, prnaam, pradres, 
prhuisnummer, prpostcode1, prpostcode2, prplaats, premail, printresse, prbrochure, 
prdatumaanv, prbrochverst FROM prospects WHERE prbrochverst = ' ' ORDER BY 
prdatumaanv";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

$_REQUEST["submit"]=isset($_REQUEST["submit"])?$_REQUEST["submit"]:"";
if($_REQUEST['submit']!="")
{
$idlist=$_POST['idlist'];
$sep=$_POST['sep'];
echo $idlist;
$array_id = explode(",", "$idlist");
foreach($array_id as $id){
    if(${"id" . $id} == 1){
        $query2 = "UPDATE prospects SET prbrochverst = '1'";
  $result2 = mysql_query($query2) or die ("Error in query: $query. " . mysql_error());
    }
}
// close connection
mysql_close($connection);
}
?>
<form method=post enctype=multipart/form-data action=<? $_SERVER['PHP_SELF']?>>
<?
// if records present
if (mysql_num_rows($result) > 0)
{
 // iterate through resultset
 // print title with links to edit and delete scripts
 while($row = mysql_fetch_object($result))
 {
 ?>
 <b><? echo formatDate($row->prdatumaanv); ?></b>
 <br>
 <font size="-1"><? echo $row->praanhef . " " . $row->prtussenv . " " . $row->prnaam;  
?><br>
 <? echo $row->pradres . " " . $row->prhuisnummer; ?><br>
 <? echo $row->prpostcode1 . " " . $row->prpostcode2 . "  " . $row->prplaats; 
?><br><br>
 <? echo $row->premail; ?><br><br>
 <? echo $row->printresse; ?><br>
<?
echo $row->prospectid;
echo "<input type=\"checkbox\" name=\"id" . $row->prospectid . "\" value=\"1\"><br>";
$idlist .= $sep . $row->prospectid;
$sep = ",";

 }
}
// if no records present
// display message
else
{
?>
 <font size="-1">Geen Prospects aanwezig</font><p>
<?
}

echo "<input type=\"hidden\" name=\"idlist\" value=\"$idlist\">";
?>
<input type=submit name=submit value=Toevoegen>
</form>

Thanks,

Frank

Reply via email to