Jump to content

Checkboxes


rghayes

Recommended Posts

OK, so I tried it with mysql_query(). It does send data to the db, but no matter which ones or how many I choose, it only sends a portion to the db. Here is my updated code:

 

<?php

$con = mysql_connect("localhost","root","YES");
    if (!$con)
    {
        die('Could not connect: ' . mysql_error());
    }
    mysql_select_db("charity_db", $con);if(isset($_POST["vote"]))
    
{$vote = $_POST["vote"];}
else {$vote=array();}

for ($i="0"; $i<count($vote); $i++) {
if(!is_numeric($vote[$i])) {$vote[$i]="";}
if(empty($vote[$i])) {unset($vote[$i]);}}

$vote = implode ("<>", $vote);
$vote = "<>".$vote."";
$sql = "INSERT INTO data_tbl (`id`, `choice`) VALUES (NULL, '$vote')";
$res=mysql_query($sql) or die (mysql_error());

echo $sql;
?>
 

Link to comment
https://forums.phpfreaks.com/topic/277706-checkboxes/page/2/#findComment-1429222
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.