PHP - Filling Checkboxes
I am having trouble setting a checkbox to "checked" if the row "published" is set to "1" (0 being not checked). I know this involves an if published==1 then print "checked", but i just cant get it to work. Any help would be greatly apprecatied:
<?php include "base.php"; $sql="SELECT * FROM project"; $result=mysql_query($sql); // Count table rows $count=mysql_num_rows($result); ?> <table width="500" border="0" cellspacing="1" cellpadding="0"> <form name="form1" method="post" action=""> <tr> <td> <table width="500" border="0" cellspacing="1" cellpadding="0"> <tr> <td align="center"><strong>Id</strong></td> <td align="center"><strong>title</strong></td> <td align="center"><strong>Published</strong></td> <td align="center"><strong>Promoted</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ $pub = $rows['publised']; ?> <tr> <td align="center"><? $id[]=$rows['id']; ?><? echo $rows['id']; ?></td> <td align="center"><? echo $rows['title']; ?></td> <td align="center"><input name="published[]" type="checkbox" id="published" value="<? echo $rows['published']; ?>"></td> <td align="center"><input name="promoted[]" type="text" id="promoted" value="<? echo $rows['promoted']; ?>"></td> </tr> <?php } ?> <tr> <td colspan="4" align="center"><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </td> </tr> </form> </table> <?php // Check if button name "Submit" is active, do this if($Submit){ for($i=0;$i<$count;$i++){ $sql1="UPDATE project SET published='$published[$i]', promoted='$promoted[$i]' WHERE id='$id[$i]'"; $result1=mysql_query($sql1); } } if($result1){ header("location:update_multiple.php"); } mysql_close(); ?> Similar TutorialsHi, my PHP code currently outputs the results from a users search by querying a backend postgresql database. As result/row is retuned to the user i would like to be able to detect whether or not they have checked a checkbox at the end of each rown in which case multiple rows can then be deleted from the database upon the user clicking a 'delete multiple records' button. I have no problem in being able to display the checkboxes on the webpage but i am a little unsure as to how to refernce them and detect which ones the user has checked. Given my database stores hostnames/IP addresses would it be best to name each checkbox to reflect the hostname or name the value it returns when checked to reflect the hostname. Given the above and that I also store the results of a users search in a $_SESSION['hosts'][][] array how can I then tie the two together? Thanks for reading. Hi all, I am not sure if this is possible but I am trying to provide people a link to a page (not mine btw) with values already filled in. So for them it's faster to submit the form. Problem is the Form is using method post. what i tried was the following but it didn't work. there is an input field: Code: [Select] <input type="text" value="" maxlength="255" size="10" id="numpoints" name="numpoints" class="inputbox required">So i thought if I just make an url like : http://godzillaeatsbananas.com/index.php?numpoints=100 it would fill in the field with a value of 100 but it doesn't Anyone might have an idea on how to accomplish this. Thanks! I have developed a form for my website that directs the user to a different site and per-populates the form on the other site with information I want. I would like to take it one step further and make the below script fill out the form on the other site and then submit the form. Currently it just fills out the form on the other site but does not submit it. Is there any way to do this? Code: [Select] <form action="http://www.privatedutyhomecare.org/sections/consumers/locator.php" method="POST"> <input name="state" size="25" type="hidden" value="MI" /> <input name="company" size="25" type="hidden" value="Affordable HomeCare" /> <button type="submit" class="imgpx"> <img src="assets/images/logos/npda.png" alt="submit" width="51" class="nothing" height="40" /> </button> </form> Ok so I have a few check box fields that are dynamically populated from a database. What I need to do is check the box if it is a selected value(this is an edit form for a product) so here's what I have but it is not working. Code: [Select] <?php include("../../../cart/includes/openDbConn.php"); $sql = "SELECT Name FROM FabricType"; $result = mysql_query($sql); $gettype = 'SELECT Type FROM FabricsTypes WHERE SKU = "'.$sku.'";'; $dogettype = mysql_query($gettype); $vtype = mysql_fetch_assoc($dogettype); $count = count($vtype); $i = 0; while($row = mysql_fetch_array($result)){ if( $i % 3 == 0 ) { echo '</tr><tr>'; } while($vtype = mysql_fetch_assoc($dogettype)){ if($vtyp['Type'] == $row['Name']){ echo '<td><label><input type="checkbox" name="typeGroup1[]" checked="checked" value="'.trim($row["Name"]).'">'.trim(ucfirst($row["Name"])).'</label</td>'; }else{ echo '<td><label><input type="checkbox" name="typeGroup1[]" value="'.trim($row["Name"]).'">'.trim(ucfirst($row["Name"])).'</label</td>'; } } $i++; } ?> When I do this it echoes nothing out. hi everyone, Im trying to make a checkout page, where if the user is logged in, the address information is called from the database and fills the form automatically, my problem is i don't know how to fill the php variables with the result of my sql query..sorry to be a complete noob but can someone explain how i would do this? <?php if (!defined('WEB_ROOT') || !isset($_GET['step']) || (int)$_GET['step'] != 1) { exit; } require_once 'loginfunctions.php'; checkCustomerLogin(); $errorMessage = ' '; ?> <?php // get the customer id from the session. $cu_id = $_SESSION['cu_id'] ?> <?php //connect to server $mysqli = mysqli_connect("localhost", "root", "", "onlinestore"); //get default shipping and payment address $mysql = "SELECT cu_id,od_shipping_first_name,od_shipping_last_name,od_shipping_address1,od_shipping_address2,od_shipping_phone,od_shipping_city,od_shipping_state,od_shipping_postal_code FROM tbl_customer WHERE $cu_id = cu_id"; $result = mysqli_query($mysql,$mysqli); $row = mysql_fetch_assoc($result); //populate form with values ? $txtShippingFirstName = 'test'; $txtShippingLastName = 'test'; $txtShippingAddress1 = 'test'; $txtShippingAddress2 = 'test'; $txtShippingPhone = 'test'; $txtShippingState = 'test'; $txtShippingCity = 'test'; $txtShippingPostalCode = 'test'; ?> <script language="JavaScript" type="text/javascript" src="library/checkout.js"></script> <table width="550" border="0" align="center" cellpadding="10" cellspacing="0"> <tr> <td>Step 1 Of 3 : Please Confirm Shipping And Payment Information </td> </tr> </table> <p id="errorMessage"><?php echo $errorMessage; ?></p> <form action="<?php echo $_SERVER['PHP_SELF']; ?>?step=2" method="post" name="frmCheckout" id="frmCheckout" onSubmit="return checkShippingAndPaymentInfo();"> <table width="550" border="0" align="center" cellpadding="5" cellspacing="1" class="entryTable"> <tr class="entryTableHeader"> <td colspan="2">Shipping Information</td> </tr> <tr> <td width="150" class="label">First Name</td> <td class="content"><input name="txtShippingFirstName" type="text" class="box" id="txtShippingFirstName" value="<?php echo $txtShippingFirstName ?>" size="30" maxlength="50"></td> </tr> <tr> <td width="150" class="label">Last Name</td> <td class="content"><input name="txtShippingLastName" type="text" class="box" id="txtShippingLastName" value="<?php echo $txtShippingLastName ?>" size="30" maxlength="50"></td> </tr> <tr> <td width="150" class="label">Address1</td> <td class="content"><input name="txtShippingAddress1" type="text" class="box" id="txtShippingAddress1" value="<?php echo $txtShippingAddress1 ?>" size="50" maxlength="100"></td> </tr> <tr> <td width="150" class="label">Address2</td> <td class="content"><input name="txtShippingAddress2" type="text" class="box" id="txtShippingAddress2" value="<?php echo $txtShippingAddress2 ?>" size="50" maxlength="100"></td> </tr> <tr> <td width="150" class="label">Phone Number</td> <td class="content"><input name="txtShippingPhone" type="text" class="box" id="txtShippingPhone" value="<?php echo $txtShippingPhone ?>" size="30" maxlength="32"></td> </tr> <tr> <td width="150" class="label">Province / State</td> <td class="content"><input name="txtShippingState" type="text" class="box" id="txtShippingState" value="<?php echo $txtShippingState ?>" size="30" maxlength="32"></td> </tr> <tr> <td width="150" class="label">City</td> <td class="content"><input name="txtShippingCity" type="text" class="box" id="txtShippingCity" value="<?php echo $txtShippingCity ?>" size="30" maxlength="32"></td> </tr> <tr> <td width="150" class="label">Postal / Zip Code</td> <td class="content"><input name="txtShippingPostalCode" type="text" class="box" id="txtShippingPostalCode" value="<?php echo $txtShippingPostalCode ?>" size="10" maxlength="10"></td> </tr> </table> <p> </p> <table width="550" border="0" align="center" cellpadding="5" cellspacing="1" class="entryTable"> <tr class="entryTableHeader"> <td width="150">Payment Information</td> <td><input type="checkbox" name="chkSame" id="chkSame" value="checkbox" onClick="setPaymentInfo(this.checked);"> <label for="chkSame" style="cursor:pointer">Same as shipping information</label></td> </tr> <tr> <td width="150" class="label">First Name</td> <td class="content"><input name="txtPaymentFirstName" type="text" class="box" id="txtPaymentFirstName" size="30" maxlength="50"></td> </tr> <tr> <td width="150" class="label">Last Name</td> <td class="content"><input name="txtPaymentLastName" type="text" class="box" id="txtPaymentLastName" size="30" maxlength="50"></td> </tr> <tr> <td width="150" class="label">Address1</td> <td class="content"><input name="txtPaymentAddress1" type="text" class="box" id="txtPaymentAddress1" size="50" maxlength="100"></td> </tr> <tr> <td width="150" class="label">Address2</td> <td class="content"><input name="txtPaymentAddress2" type="text" class="box" id="txtPaymentAddress2" size="50" maxlength="100"></td> </tr> <tr> <td width="150" class="label">Phone Number</td> <td class="content"><input name="txtPaymentPhone" type="text" class="box" id="txtPaymentPhone" size="30" maxlength="32"></td> </tr> <tr> <td width="150" class="label">Province / State</td> <td class="content"><input name="txtPaymentState" type="text" class="box" id="txtPaymentState" size="30" maxlength="32"></td> </tr> <tr> <td width="150" class="label">City</td> <td class="content"><input name="txtPaymentCity" type="text" class="box" id="txtPaymentCity" size="30" maxlength="32"></td> </tr> <tr> <td width="150" class="label">Postal / Zip Code</td> <td class="content"><input name="txtPaymentPostalCode" type="text" class="box" id="txtPaymentPostalCode" size="10" maxlength="10"></td> </tr> </table> <p> </p> <table width="550" border="0" align="center" cellpadding="5" cellspacing="1" class="entryTable"> <tr> <td width="150" class="entryTableHeader">Payment Method </td> <td class="content"> <input name="optPayment" type="radio" id="optPaypal" value="paypal" checked="checked" /> <label for="optPaypal" style="cursor:pointer">Paypal</label> <input name="optPayment" type="radio" value="cod" id="optCod" /> <label for="optCod" style="cursor:pointer">Cash on Delivery</label></td> </tr> </table> <p> </p> <p align="center"> <input class="box" name="btnStep1" type="submit" id="btnStep1" value="Proceed >>"> </p> </form> i want to make a forum that nobody can fill that through any software automatically i make this one with java script authentications but some one also make a break of this and and he fill this software only in one click with automatic way this one which i make http://www.ebs-ads.com/advertising/forms.php?id=4&name=Abel any better solutions using php or any other function that users must have to post every input field separately manually ..if yes Please suggest me thanks Hello all, looking for some help here as I seem to be fairly stuck... this yields no results at all and I give up, I need help!
The user should be able to select an employee from a select field, and based on their selected we should be able to grab the start time and end time of that empoyee, which resides on the database.
My form:
<form action=".php" name="absence" id="absence" method="post"> Employee: <select name="empid" class="clockinputs" required> <option value=""></option> <option value='20'>Bob Jones</option> <option value='13'>Bob Phones</option> <option value='93'>Bob Lomes</option> <option value='30'>Bob Somes</option> <option value='107'>Bob Pomes</option> <option value='74'>Bob Womes</option> </select> Shift Start: <input type="text" name="startshift" id="startshift" class="clockinputs" data-inputmask="'mask': '99:99:99'" required> Shift End: <input type="text" name="endshift" id="endshift" class="clockinputs" data-inputmask="'mask': '99:99:99'" required> <input type="hidden" name="eid" value="<?php echo $row{'EID'}; ?>"> <input type="submit" value="Save"> </form>Javascript: <script type="text/javascript"> jQuery(document).ready(function(){ jQuery('#empid').live('change', function(event) { $.ajax({ url : 'absence-get.php', type : 'POST', dataType: 'json', data : $('#absence').serialize(), success: function( data ) { for(var id in data) { $(id).val( data[id] ); } } }); }); }); </script>And absence-get.php: <?php $e = $_POST['empid']; $result = mysql_query("SELECT * FROM employees WHERE EID='$e' "); $row = mysql_fetch_array($result, MYSQL_ASSOC) $startshift = $row{'startshift'}; $endshift = $row{'endshift'}; $arr = array( 'input#startshift' => $startshift , 'input#endshift' => $endshift ); echo json_encode( $arr ); ?>Anyone spot anything? Thank you! Hello all, I have three text fields ( hosteladmissionnumber,branch & Semester) and three text boxes in a form. When i provide the hostel admission number , the corresponding branch semester must be acquired from the registrationtable in DB and fill it in text boxes. How can i do it? any help would be appreciated. Thanks. I have pasted the code below. [syntax=php] <?php session_start(); $hostad=$_POST['hosteladmissionno']; $sem=$_POST['student_name']; $sem=$_POST['semester']; $con=mysql_connect('localhost','root',''); if(!$con) { die('Unable to connect'.mysql_error()); } mysql_select_db('hostel',$con); //i have to insert the hosteladmission in payment too..but no need to insert semester and branch $r1="INSERT INTO payment(hosteladmissionno) values ('$hostad')"; mysql_close($con); ?> /HTML PART <form action='payment.php' method='POST' name='form1'> <center> <table> <tr><td><b>Admission No:</b></td><td><input type='text' name='hosteladmissionno'></td></tr> <tr><td><b>Student Name:</b></td><td><input type='text' name='student_name'></td></tr> <tr><td><b>Semester:</b></td><td><input type='text' name='semester'></td></tr> [/syntax] This is really blowing my mind... the code is as follows the table, the column names everything is right and contains information but the variables aren't being filled... I don't get it... Anyone have any ideas or options I might not have thought of for debugging? $item_name = ("SELECT * FROM items WHERE id = '$grab_item'"); $que_items = mysql_query($item_name); while ($item_todel = mysql_fetch_array($que_items, MYSQL_BOTH)) { $name = $item_todel['name']; $desc = $item_todel['desc']; } echo ($name . "<br>" . $desc . "<br>" . $grab_item); the only variable thats set is grab_item, fetch_array throws no errors, if I plug in the query straight to the sql I get all the proper information... It's just not filling the two variables.... I am trying to convert and old website from mysql database to sqlite. One of the chores it must do is collect information from the database and put it in a list/menu select box on a page so the user can choose which item to pursue.
In the following (incomplete) snippit, I am doing something incorrectly because the sql query does get the proper information (I can put it in a table on the page just fine). But I'm having trouble getting the information into the select options on a list/menu. It appears to be putting them all, one after the other in the first option spot. The last one seems to be the only one of 6 or 7 that shows up.
It's been 10 or 12 years since I've messed with php, so I think I'm way behind... any help would be appreciated.
---------------------------
<form action="sqlPropDisplay.php" method="post" id="Residential"> Here's my code, whenever I try to fill the form it gives me that error "Oops! Something went wrong. Please try again later"
Code: <?php // Include config file require_once "config.php"; // Define variables and initialize with empty values $CodEntrega = $CodCliente = $Dia = $Pagamento = $Funcionario = ""; $CodEntrega_err = $CodCliente_err = $Dia_err = $Pagamento_err = $Funcionario_err = ""; // Processing form data when form is submitted if($_SERVER["REQUEST_METHOD"] == "POST"){ // Validate name $input_CodEntrega = trim($_POST["CodEntrega"]); if(empty($input_CodEntrega)){ $CodEntrega_err = "Insira o codigo de entrega"; } else{ $CodEntrega = $input_CodEntrega; } // Validate address $input_CodCliente = trim($_POST["CodCliente"]); if(empty($input_CodCliente)){ $CodCliente_err = "Insira o codigo do cliente"; } else{ $CodCliente = $input_CodCliente; } // Validate salary $input_Dia = trim($_POST["Dia"]); if(empty($input_Dia)){ $Dia_err = "Insira a data da entrega"; } else{ $Dia = $input_Dia; } $input_Pagamento = trim($_POST["Pagamento"]); if(empty($input_Pagamento)){ $Pagamento_err = "Insira o tipo de pagamento"; } else{ $Pagamento = $input_Pagamento; } $input_Funcionario = trim($_POST["Funcionario"]); if(empty($input_Funcionario)){ $Funcionario_err = "Insira o codigo do funcionario"; } else{ $Funcionario = $input_Funcionario; } if(empty($CodEntrega_err) && empty($CodCliente_err) && empty($Dia_err) && empty($Pagamento_err) && empty($Funcionario_err)){ $sql = "INSERT INTO entrega(CodEntrega, CodCliente, Dia, Pagamento, Funcionario) VALUES (?, ?, ?, ?, ?)"; if($stmt = mysqli_prepare($link, $sql)){ // Bind variables to the prepared statement as parameters mysqli_stmt_bind_param($stmt, "ssdss", $param_CodEntrega, $param_CodCliente, $param_Dia, $param_Pagamento, $param_Funcionario); // Set parameters $param_CodEntrega= $CodEntrega; $param_CodCliente = $CodCliente; $param_Dia = $Dia; $param_Pagamento = $Pagamento; $param_Funcionario = $Funcionario; if(mysqli_stmt_execute($stmt)) { header("location: home.html"); exit(); } else { echo "Oops! Something went wrong. Please try again later."; } } // Close statement mysqli_stmt_close($stmt); } // Close connection mysqli_close($link); } ?> <!DOCTYPE html> <html lang="en"> <head> <title>Projeto TW</title> <link rel="stylesheet" href="css/milligram.css"> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> * { box-sizing: border-box; } body { font-family: Arial, Helvetica, sans-serif; } /* Style the header */ header { background-color: #B0171F; padding: 30px; text-align: center; font-size: 35px; color: white; } /* Create two columns/boxes that floats next to each other */ nav { float: left; width: 30%; height: 300px; /* only for demonstration, should be removed */ background: #ccc; padding: 20px; } /* Style the list inside the menu */ nav ul { list-style-type: decimal; padding: 0; } article { float: left; padding: 20px; width: 70%; background-color: #f1f1f1; height: 300px; /* only for demonstration, should be removed */ } /* Clear floats after the columns */ section::after { content: ""; display: table; clear: both; } /* Style the footer */ footer { background-color: #B0171F; padding-top: 7px; padding-bottom: 7px; text-align: middle; color: white; position: relative; bottom: 0; } #content-wrap { padding-bottom: 2rem; /* Footer height */ } #page-container { position: relative; } @media (max-width: 600px) { nav, article { width: 100%; height: auto; } } .dropbtn { background-color: #4CAF50; color: white; padding: 16px; font-size: 16px; border: none; } .dropdown { position: relative; display: inline-block; } .dropdown-content { display: none; position: absolute; background-color: #f1f1f1; min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); z-index: 1; } .dropdown-content a { color: black; padding: 12px 16px; text-decoration: none; display: block; } .dropdown-content a:hover {background-color: #ddd;} .dropdown:hover .dropdown-content {display: block;} .dropdown:hover .dropbtn {background-color: #3e8e41;} </style> </head> <body> <header> <div class="head1">PROJETO DE TW</div> <div class="head2">Gestão de uma BD</div> </header> <div class='container'> <div class='navbar'> <ul> <li><a class="active" href="home.html">Home</a></li> <li><a href="#consultar">Consultar</a></li> <li><a href="tabela.html">Inserir</a></li> <li><a href="#alterar">Alterar</a></li> <li><a href="#eliminar">Eliminar</a></li> </ul> </div> <div class = "body_sec"> <section id="Content"> <h3>INSERIR DADOS DE ENTREGA</h3> <button type="button" >ENTREGA</button> </section> <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post"> <div class="form-group"> <label>CodEntrega</label> <input type="text" name="CodEntrega" class="form-control <?php echo (!empty($CodEntrega_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $CodEntrega; ?>"> <span class="invalid-feedback"><?php echo $CodEntrega_err;?></span> </div> <div class="form-group"> <label>CodCliente</label> <input type="text" name="CodCliente" class="form-control <?php echo (!empty($CodCliente_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $CodCliente; ?>"> <span class="invalid-feedback"><?php echo $CodCliente_err;?></span> </div> <div class="form-group"> <label>Dia de Entrega</label> <input type="date" name="Dia" class="form-control <?php echo (!empty($Dia_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $Dia; ?>"> <span class="invalid-feedback"><?php echo $Dia_err;?></span> </div> <div class="form-group"> <label>Pagamento</label> <input type="text" name="Pagamento" class="form-control <?php echo (!empty($Pagamento_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $Pagamento; ?>"> <span class="invalid-feedback"><?php echo $Pagamento_err;?></span> </div> <div class="form-group"> <label>Codigo do Funcionario</label> <input type="text" name="Funcionario" class="form-control <?php echo (!empty($Funcionario_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $Funcionario; ?>"> <span class="invalid-feedback"><?php echo $Funcionario_err;?></span> </div> <input type="submit" class="btn btn-primary" value="Submit"> <a href="home.html" class="btn btn-secondary ml-2">Cancel</a> </form> </div> </div> </div> </div> </body> </html>
Edited May 10 by Barand code tags added Hey guys I am confused about using checkboxes to delete entries. Yes, just for delete. Codes for table: Code: [Select] echo "<form method = \"post\" action=\"{$_SERVER['PHP_SELF']}\"> <table> <tr> <td width=\"55\" class=\"formLabelsS2\"><input type=\"submit\" name=\"delete\" value=\"Delete\" id=\"delete\"></td> <td> Please note that entries could not be restored once they are deleted!</td> </tr> </table> </form>"; echo "<table class=\"sortable\" id=\"query_quick1\" width=\"100%\" >\r\n"; echo "<thead>"; echo "\t<tr><th></th><th></th><th>Up.dated Query</th><th>Link</th><th>Promoter</th><th> # </th><th>Up?</th> <th>Ana. Area</th><th> # </th><th>Up?</th> <th>C. Type</th><th> # </th><th>Up?</th><th>Other C. Type</th> <th> # </th><th>Up?</th><th>Gen. Back.</th><th> # </th><th>Up?</th> <th>Other Gen. Back.</th><th> # </th><th>Up?</th><th>Author</th><th> # </th><th>Up?</th> <th>Other</th><th> # </th><th>Up?</th><th>Date</th><th>Email</th> <th>F. Name</th><th>L. Name</th></tr>\r\n"; echo "</thead>"; if($result->num_rows){ while ($row = $result->fetch_array()){ $RowCount ++; $row_color = ($RowCount % 2) ? $color1 : $color2; echo "\t<tr class=\"$row_color\" > <form method = \"post\" action=\"{$_SERVER['PHP_SELF']}\"> <td><input type =\"hidden\" name = \"id\" value=\"{$row['id']}\"></td> <td><input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"{$rows['id']} \"></td> <td>{$row['query']}</td><td>{$row['link']}</td> <td>{$row['pro']}</td><td>{$row['pro_count']}</td> <td>{$row['pro_update']}</td> <td>{$row['ana']}</td><td>{$row['ana_count']}</td><td>{$row['ana_update']}</td> <td>{$row['cell']}</td><td>{$row['cell_count']}</td><td>{$row['cell_update']}</td> <td>{$row['cellother']}</td><td>{$row['cellother_count']}</td><td>{$row['cellother_update']}</td> <td>{$row['gen']}</td><td>{$row['gen_count']}</td><td>{$row['gen_update']}</td> <td>{$row['genother']}</td><td>{$row['genother_count']}</td><td>{$row['genother_update']}</td> <td>{$row['author']}</td><td>{$row['author_count']}</td><td>{$row['author_update']}</td> <td>{$row['other']}</td><td>{$row['other_count']}</td><td>{$row['other_update']}</td> <td>{$row['date']}</td><td>{$row['Email']}</td> <td>{$row['First_Name']}</td><td>{$row['Last_Name']}</td> </form></tr>"; } } echo "</table>"; php for deleting entries: Code: [Select] } elseif(isset($_SESSION['user_id']) AND isset($_POST['delete'])){ $connect=db_connect_2(); foreach($_POST['checkbox'] as $check) { $delete = mysqli_query("DELETE FROM mailing_list WHERE id = '$check'"); } $body = "mailingList.php"; } Error pops up: Warning: Invalid argument supplied for foreach() Of course no entries are deleted due to this warning. Help would be greatly appreciated as always Thanks. I am using php to display information from a MySQL database. It starts with three radio buttons and upon selecting one it will display some information for all items in that category. I have all this working but I need to add check boxes for each item and when submitted it will display all information for those items. Below is the bit where I need to insert check box and I'm also attaching my php (leaving out html form and database as it shouldn't be required to help). I must do this as soon as possible, please help. Thanks.. Code: [Select] while ($row = mysql_fetch_assoc ($result_set)) { $ID = $row['id']; $auth = $row['entertainerauthor']; $title = $row['title']; $media = $row['media']; $feature = $row['feature']; printf ("\nID: %s",$ID); printf ("\nEntertainer/Author: %s",$auth); printf ("\nTitle: %s",$title); printf ("\nMedia: %s",$media); printf ("\nFeatu %s",$feature); print "\n"; } for example i have a form like this Code: [Select] <form name="input" action="page2.php" method="post"> <table cellpadding="20" width="100%"> <!-- BEGIN query --> <tr> <td> <img src="../eImages/{IMAGE}.jpg" style="width:200px;height:200px;" /> </td> <td> {EVENTTYPE}</br> {DPLACE} </br> {NAME}</br> {SPEAKERS}</br> {LOC}</br> {STREET}</br> {TIME} </br> </td> <td> <input type="checkbox" name="eventlist"> </td> </tr> <!-- END query --> </table> <input type="submit" value="Submit" /> </form> this is all dynamically loaded each time from a database so it could have several trs of this formal my goal is to only select 3 of them and then submit the form this is will make a checkbox for each one including all the details but the problem is that the checkboxes will all have the same name as oneanother is there a way to increment the checkbox name value each time it goes through the while loop in the database? thanks Okay I am working on a mail script and my only problem is, is that when you select mutiple delete boxes, it only deletes one. How do I get it to delete all of the checked boxes? hi guys....i have a doubt on the checkbox use and validation in php.... how do you enable one checkbox and once it is checked the others would be disabled automatically....... is this possible in php or do we use javascript.... ur guidances and help is appreciated in advance Hey Everyone, been a while. I need some help with an easy one. I'm brain farting and blanking out. Someone please help. HTML form that has checkboxes: Code: [Select] <form ...> <input name="check1" type="checkbox" value="Value 1"> </form> PHP Code $post_check1= $_POST["check1"]; $body .= "check1: ".$post_check1."\n"; The form doesn't return the value when checked. What I am missing? I know it's something simple. Please help. Thanks. I'm very new to php. I'm still learning slowly. I'm currently doing a page where im showing all my patient records but there's checkboxes to tick and select a particular patient and go to next page.php to see the details of their history. Here is my codings <?php include ("includes/db.php"); ?> <table width="455" align="center" height="129" border="0" cellpadding="0" cellspacing="1"> <tr> <td width="453"><form name="form1" method="post" action="patienthistory.php"> <table width="900" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <tr> <td align="center" bgcolor="#FFFFFF">#</td> <td align="center" bgcolor="#FFFFFF" width="100"><strong>Patient ID</strong></td> <td align="center" bgcolor="#FFFFFF" width="200"><strong>Patient Name</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Patient I/C</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Patient Mobile</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Patient Address</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>City</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>State</strong></td> </tr> <?php $sql = "SELECT patient_id, patient_name, patient_ic, patient_mobile, patient_add, patient_city, patient_state FROM patient_healthcare ORDER by patient_id ASC"; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); while(list($patient_id,$patient_name,$patient_ic,$patient_mobile,$patient_add,$patient_city,$patient_state)=mysql_fetch_row($result)){ $checked="$patient_id" ; echo '<tr><td><input name="checkbox[]" type="checkbox" value="'.$patient_id.'" '.$checked.'/></td><td>'.$patient_id.'</td><td>'.$patient_name.'</td><td>'.$patient_ic.'</td><td>'.$patient_mobile.'</td><td>'.$patient_add.'</td><td>'.$patient_city.'</td><td>'.$patient_state.'</td></tr>'."\n"; } ?> When i tick one boxes and press Select. The next page.php shows all the records. I just want a particular record show not all. Need help. Help is appreciated. how would i get checkboxes to work. I have tried: $JobCategories = ($_GET['JobCategories[]']) ? $_GET['JobCategories[]'] : $_POST['JobCategories[]']; html looks like: <li><input name="JobCategories[]" type="checkbox" value="Admin" /> Admin</li> <li><input name="JoCategories[]" type="checkbox" value="Campaigning" /> Campaigning</li> |