Jump to content

AccuCORE

New Members
  • Posts

    3
  • Joined

  • Last visited

AccuCORE's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you for your help, I found a new way with javascript Jquery 1.5.2 and it works fine. <script type="text/javascript"> function updateTextArea() { var allVals = []; $('.tagstates :checked').each(function(i) { allVals.push((i!=0?"\r\n":"")+ $(this).val()); }); $('#statesel').val(allVals).attr('rows',allVals.length) ; } $(function() { $('.tagstates input').click(updateTextArea); updateTextArea(); }); </script> <textarea name="active" id="statesel"></textarea> <div class="tagstates"> <label><input type="checkbox" value="2D Animation">2D Animation</label> <label><input type="checkbox" value="3D Animation">3D Animation</label> <label><input type="checkbox" value="Animatronics">Animatronics</label> <label><input type="checkbox" value="Architectural">Architectural</label> <label><input type="checkbox" value="Cartoon">Cartoon</label> <label><input type="checkbox" value="Cell Animation">Cell Animation</label> <label><input type="checkbox" value="Character Animation">Character Animation</label> <label><input type="checkbox" value="Cut & Paste">Cut & Paste</label> <label><input type="checkbox" value="Doodle">Doodle</label> <label><input type="checkbox" value="HDR">HDR</label> <label><input type="checkbox" value="High Speed">High Speed</label> <label><input type="checkbox" value="Illustration">Illustration</label> <label><input type="checkbox" value="Live Action">Live Action</label> <label><input type="checkbox" value="Macro">Macro</label> <label><input type="checkbox" value="Motion Design">Motion Design</label> <label><input type="checkbox" value="Motion Graphics">Motion Graphics</label> <label><input type="checkbox" value="Moving Installation">Moving Installation</label> </div>
  2. That is a test code, I thought it worked but nothing. This is one give me the "Array" in stored in database, what can I do for this code? <?php require_once "../lakota/config.php"; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (isset($_POST['faction'], $_POST['stations'], $_POST["active"], $_POST['pending'], $_POST['influence'], $_POST['id_fact'])) { $sql = "INSERT INTO lakotabgs (faction, stations, active, pending, influence, id_fact) VALUES (?,?,?,?,?,?)"; if ($stmt = $link->prepare($sql)) { $stmt->bind_param("ssssss", $_POST['faction'], $_POST['stations'], $_POST["active"], $_POST['pending'], $_POST['influence'], $_POST['id_fact']); if ($stmt->execute()) { header("location: ../lakota/index.php"); exit(); } else { echo "Error! Try again later."; } $stmt->close(); } } $link->close(); } ?>
  3. Hello I need a great help for my problem, I tried to insert multiple checkboxs for "$_POST active" in my CRUD and the values must be saved in the database but will be saved as "Array" everytime. I used this code but where exactly I need to put it? foreach($_POST['active'] as $act){//query? } Here the PHP code <?php require_once "../lakota/config.php"; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (isset($_POST['faction'], $_POST['stations'], $_POST["active"], $_POST['pending'], $_POST['influence'], $_POST['id_fact'])) { if(isset($_POST["submit"])){ $activearr=$_POST["active"]; $newvalues= implode(",", $activearr); include_once "../lakota/checkboxClass.php"; $checkBoxClass=new checkboxClass(); echo $checkBoxClass->addtoDatabase($newvalues); } $sql = "INSERT INTO lakotabgs (faction, stations, active, pending, influence, id_fact) VALUES (?,?,?,?,?,?)"; if ($stmt = $link->prepare($sql)) { $stmt->bind_param("ssssss", $_POST['faction'], $_POST['stations'], $_POST["active"], $_POST['pending'], $_POST['influence'], $_POST['id_fact']); if ($stmt->execute()) { header("location: ../lakota/index.php"); exit(); } else { echo "Error! Try again later."; } $stmt->close(); } } $link->close(); } ?> HTML code <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Add new info</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> </head> <body> <form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post"> <label><b>Active States</b></label> <input name="active[]" class="form-control" id="example1" type="checkbox" value="None" /> <label for="example1">None</label> <input name="active[]" class="form-control" id="example2" type="checkbox" value="Everybody" /> <label for="example2">Everybody</label> <input name="active[]" class="form-control" id="example3" type="checkbox" value="Unknown" /> <label for="example3">Unknown</label> <input type="submit" id="submit" name="submit" class="btn btn-primary" value="Add new info"> <a href="../lakota/index.php" class="btn btn-default">Back</a> </form> </body> </html>
  4. Hello guys, as you read the title I'm new to the PHP world and I hope to learn a lot. 😀
×
×
  • 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.