PHP - At Least One Array Field Row Should Be Selected (not Checkboxes)
Have a look at this image
Here is the part of the form code that makes them into arrays $sql="select * from products"; $res=mysql_query($sql); WHILE($fetch=mysql_fetch_assoc($res)){ echo "<td><input type=hidden name='desBox[]' id='desBox[]' value='".$fetch['prod_id']."'>".$fetch['prod_name']."</td> <td><input type=text id=quantBox[] maxlength=6 name=quantBox[]></td> <td><input type=text maxlength=6 id=teethBox[] name=teethBox[]></td>"; echo "</tr>";} Similar Tutorialshow to cross reference $_POST array 'checkboxes[]' with mysql field I have a form that is submitted so the user can select which results to print. but I am having problems getting the results to show correctly. how do I correctly cross reference the form data with the mysql Code: [Select] $getRequests = mysql_query("SELECT * FROM requests WHERE `customer_email`='{$_SESSION['FM_user']}'"); while($request = mysql_fetch_assoc($getRequests)) { if (!in_array($request['request_id'],array($_POST[request]))) { echo '<li style="font-size:10px; border-bottom: 0.1em solid #D0D0D0"> <div class="leftfloat"> <input type="checkbox" name="request[]" value="',$request['request_id'],'"> </div> <div class="leftfloat"> <em>',$request['request_id'],'</em> </div><div class="leftfloat"> | </div> <div class="leftfloat"> <em>',$request['customer_name'],'</em> </div><div class="leftfloat"> | </div> <br style="clear:both"> </li>'; } } Hello all, i have a table that displays data from mysql, now i want to update multiple rows from that table with checkboxes, the value will basically just switch from 'new' to 'done' so far i have this: Code: [Select] <tbody> <tr class="first"> </tr> <?php $ticketde=0; while ($ticketde < $numpscde) { $f1pscde=mysql_result($ticketresultde,$ticketde,"id"); $f2pscde=mysql_result($ticketresultde,$ticketde,"ticket"); $f4pscde=mysql_result($ticketresultde,$ticketde,"date"); $f5pscde=mysql_result($ticketresultde,$ticketde,"ip"); $f6pscde=mysql_result($ticketresultde,$ticketde,"done"); $setdone = ($f6pscde["done"] == 'n') ? "<a href=\"donepsc.php?id=".$f1pscde."\"><img src=\"ico_new.gif\" alt=\"new\" /></a>" : $f6pscde["done"]; if(isset($_POST['setdone'])){$checkbox = $_POST['checkbox']; $id = "('" . implode( "','", $checkbox ) . "');" ; $sql = "UPDATE ticket SET done='done' WHERE id='$f1pscde'"; $result = mysql_query($sql) or die(mysql_error()); } ?> <tr class="first"> <td class="tc"><font face="Arial, Helvetica, sans-serif"><?php echo $f1pscde; ?></font></td> <td class="tc"><font face="Arial, Helvetica, sans-serif"><?php echo $f2pscde; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f4pscde; ?></font></td> <td class="tc"><font face="Arial, Helvetica, sans-serif"><?php echo $f5pscde; ?></font></td> <td class="tc"><font face="Arial, Helvetica, sans-serif"><?php echo $setdone; ?></font></td> <td class="tc"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $f1pscde['id']; ?>"></td> </tr> <?php $ticketde++; } ?> </tbody> </table> <center><input type="submit" name="setdone" id="setdone" value="Set selected to done" class="button"/> - <input type="submit" name="exporttxt" id="exporttxt" value="Export selected to .txt" class="button"/> </center> </fieldset> </form> I found that checkbox code sample on some other site and tried to implement it, i don't really know where to go from here, as it's a total mess to me now, any help would be greatly appreciated. Hello All,
Being a newbie at PHP coding I'm at my wits end trying to figure out:
a) how to pull-in values from a delimeted text field (in a MySQL table) and check/select the appropriate checkboxes, based on the values that were stored in the text field,
b) how to write any changes (made by the user) back to the tables' text field.
Note that this is for an "update.php" file/process.
My "create.php" file/process uses the following HTML to display and accept the checkbox values:
<div class="control-group"> <label class="control-label">Limited Time Sale Days:</label> <div class="lts-checkboxes-container"> <label class="indent-to-the-left"> <input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='F'><span class='no-highlight'>Fri</span> </label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='Sa'><span class='no-highlight'>Sat</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='Su'><span class='no-highlight'>Sun</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='M'><span class='no-highlight'>Mon</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='Tu'><span class='no-highlight'>Tue</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='W'><span class='no-highlight'>Wed</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='Th'><span class='no-highlight'>Thu</span></label> </div> </div>And the code (certainly not the best code in the world, but it works) to collect, delemit/concatenate, and save to DB is as follows: if(empty($_POST['limited_time_sale'])) { // echo("You didn't select any weekday."); $selected_lts = ''; $limited_time_sale = ''; } else { $limited_time_sale = $_POST['limited_time_sale']; $N = count($limited_time_sale); $selected_lts = ''; // echo("You selected $N DoW(s): "); for($i=0; $i < $N; $i++) { // echo($limited_time_sale[$i] . " "); if ($i < ($N - 1)) { $selected_lts .= $limited_time_sale[$i] . "-"; } else { $selected_lts .= $limited_time_sale[$i]; } } } if(!empty($selected_lts)) { $limited_time_sale = $selected_lts; }Now, I've figured out how to bring-in, and separate the stored values using the following code, however I have no idea what to do next...in order to have only the approprite boxes checked/selected (in the event that all boxes were not selected during the create stage). $limited_time_sale = isset($values['limited_time_sale']) ? $values['limited_time_sale'] : ''; $checked_lts = explode("-", $limited_time_sale);In my "update.php" file, the HTML for the forms' checkboxes is as follows: <div class="control-group"> <label class="control-label">Limited Time Sale Days:</label> <div class="lts-checkboxes-container"> <label class="indent-to-the-left"> <input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='F' <?php echo $lts1; ?>><span class='no-highlight'>Fri</span> </label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='Sa' <?php echo $lts2; ?>><span class='no-highlight'>Sat</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='Su' <?php echo $lts3; ?>><span class='no-highlight'>Sun</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='M' <?php echo $lts4; ?>><span class='no-highlight'>Mon</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='Tu' <?php echo $lts5; ?>><span class='no-highlight'>Tue</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='W' <?php echo $lts6; ?>><span class='no-highlight'>Wed</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='Th' <?php echo $lts7; ?>><span class='no-highlight'>Thu</span></label> </div> </div>Attached picture shows that selected checkboxes are saved to the text field as/in the format of "F-Sa-Su-M-Tu-W-Th" - if all checkboxes/weekdays were selected....or as "Sa-M-W-Th" - if only Sat, Mon, Wed, and Thu checkboxes were selected Thanks. Attached Files checkbox-Question.png 403.99KB 0 downloads Hello! I been trying to figure how first read a Google docs CSV (live) to be shown as a custom HTML. The CSV have 50 lines and each line have 15 cells. With a bit searching i figure out to this : Code: [Select] <?PHP $file_handle = fopen("https://docs.google.com/spreadsheet/pub?key=0Aus5xZRHSuhydGpmcXBRN0Z2WXM5Sks3TlgydF92R1E&single=true&gid=3&output=csv", "r"); while (!feof($file_handle) ) { $line_of_text = fgetcsv($file_handle, 1024); print "<custom code>" . $line_of_text[0] . $line_of_text[1]. $line_of_text[2] . $line_of_text[3] . $line_of_text[4] . $line_of_text[5] . $line_of_text[6] . $line_of_text[7] . $line_of_text[8] . $line_of_text[9] .$line_of_text[10] . $line_of_text[11] . $line_of_text[12] . $line_of_text[13] . $line_of_text[14] . $line_of_text[15] . "<br>"; } fclose($file_handle); ?> But what i would need is to view only the row that have the value "(T01S)" in the first cell "A2" or first "$line_of_text[0]" and the header (first line). I was thinking about just to show a "desired_line" would not help me as if i add a line in the middle many pages would show the wrong line. Also is it any easy way to show one full line except the first cell? So i can have a custom code on that field? And also so i do not need every pages code if i add more fields? After many hours of searching i would be very happy for any kind of help! Yesterday, I created a topic about how I could update records and I managed to achieve that successfully. Now I have another dilemma. When I have a specific record I want to update, I want to change a category ID of an product (e.g. change it from 1 to 2) but how do I go about doing this? Here is my code thus far: Code: [Select] <?php require_once ('./includes/config.inc.php'); require_once (MYSQL); $id=$_GET['prodID']; $results = mysqli_query($dbc, "SELECT * FROM product WHERE prodID=".$_GET['prodID'].""); $row = mysqli_fetch_assoc($results); ?> <form action="" method='POST'> Product ID: <input type="text" value="<?php echo $row['prodID'];?>" name="prodID" /> <br /> Product: <input type="text" value="<?php echo $row['product'] ;?>" name="product" /> <br /> Product Description: <input type="text" value="<?php echo $row['prod_descr'] ;?>" name="prod_descr" /> <br /> Category: <select name="category"> <option value="<?php echo $row['catID'];?>"></option> </select> Price: <input type="text" value="<?php echo $row['price'] ;?>" name="price" /> <br /> In Stock: <input type="text" value="<?php echo $row['stock'] ;?>" name="stock" /> <br /> <br /><input type="submit" value="save" name="save"> </form> <?php if(isset($_POST['save'])) { $id = $_POST['prodID']; $product = $_POST['product']; $descr = $_POST['prod_descr']; $price = $_POST['price']; $stock = $_POST['stock']; // Update data $update = mysqli_query($dbc, "UPDATE product SET product='$product', prod_descr='$descr', price='$price', stock='$stock' WHERE prodID=".$_GET['prodID'].""); header( 'Location: update_save.php' ) ; } ?> Hi Good day Can someone pls help me regarding with this matter. I have a page for inserting records. And I have a combobox that is fetched through the specific field in database. I also have a table of records, for each row i have an href edit which throws the values to its respective texbox and combobox. THE PROBLEM is that when i click the href edit, the value from a selected row was not displayed from the combobox Code: [Select] $new_array2=array_diff($my_array,$itemIds); $updatedb = mysql_query("UPDATE content_type_ads SET field_expire_value = '666' WHERE $new_array2 = field_item_id_value"); "$new_array2" has only 12 digit numbers for each item in the array, and I want to match them to the "field_item_id_value" field in the table, updating the "field_expire_value" field for the record where they match. I know I am close because the UPDATE code works before I add the WHERE statement (it of course adds '666' to EVERY field, but for a noobie it's a start!). Hello to everyone,
I have a strange problem and I'm not able to solve it by myself and I need your help!
I have three simple checkboxes that process via POST their value. But with PHP I cannot have an array with the three indexes (if everyone checked) but only an array with the first checkbox checked. The code is very simple:
<?php $scelta = isset($_POST['user_rights']) ? $_POST['user_rights'] : array(); if (isset($_POST["user_rights"])){ print_r($scelta);}else{ ?> <form method="post"><input type="checkbox" name="user_rights[]" value="0"> 0<br><input type="checkbox" name="user_rights[]" value="1"> 1<br><input type="checkbox" name="user_rights[]" value="2"> 2 <input type="submit"></form> <?php} ?>The output if I check all the checkboxes is: Array ( [0] => 0 ) If I try this code on another server it works (it returns the complete array), but if i run it on my web server, it doesn't (it returns only the first item). Do you have any experience with this error? Do you know if there is some configuration to change? Thanks in advance. Rob Hi
I'm totally green when it comes to php, but am learning it the hard way. Any help is appreciated.
I have a form the currenty uses a custom taxonomy but it has a text field, and I want it to call and list the taxonomy items with checkboxes so instead of entering words the visitor can just multiple check off the taxonomies that relate to them.
It's a job board, this is the job skill part that relates to their expertise.
There is a job category in the form, and I tried to use the syntax to get the taxonomy and implode it but
I really don't know what I'm doing.
See the "skills" item? I want to make that a bunch of checkboxes to allow selection the the pre defined resume_skills taxonomy.
http://outsourcing.j...it-resume-free/
Any help would be great, and I'm not sure what code I need to put in here.
Mark
This is my code: $episodes = mysql_query("SELECT * FROM episode_links WHERE episode_id = '".$episode_id."' AND moderated='1' ORDER BY host ASC"); while ($episode = mysql_fetch_assoc($episodes)) { // code here } and in my host table, I have values like this: Fileserve.com MegaUpload.com Rapidshare.com Torrent And I would like a way to sort this so that only the Fileserve links appear on the top ( the first few results), then all the others. can anyone help me? To generate the stockroom drop down list function einv_generateStockrmSelectDropdown($Stockrm,$field,$dropdown) { //connect to database base_connectDatabase(); echo "<select id=\"stockrm\" name=\"".$field."[]\" multiple=\"multiple\" style=\"align:left\" class=\"form-control\">"; if (isset($Stockrm) && ($Stockrm != "")) { $stockrmname = einv_getStockrmDetail($Stockrm); echo "<option value=\"". $Stockrm ."\">". $stockrmname['einv_stockrm_name'] ."</option>"; } else { $Stockrm = 0; } $getStockrmSQL = base_executeSQL("SELECT * FROM einv_stockroom WHERE einv_stockrm_id<>" . $Stockrm . " ORDER BY einv_stockrm_name"); while ($Stockrmdata_row = base_fetch_array($getStockrmSQL)) { if (base_num_rows($getStockrmSQL)!= 0) { echo "<option value=\"".$Stockrmdata_row['einv_stockrm_id']."\">".$Stockrmdata_row['einv_stockrm_name']."</option>"; } } echo "</select>"; echo "<script src=\"../terms_base/js/jquery.multiple.select.js\"></script>"; //Input some codes to split the dropdown and make it into the setSelects. By default, the first time = AutoSelectAll if(isset($dropdown) && ($dropdown != "")) { //dropdown = 1;2;3 $SDDArrays = explode(";", $dropdown); $countTrap0 = count($SDDArrays); $drop = "$('#stockrm').multipleSelect(\"setSelects\", ["; $counting = 1; foreach ($SDDArrays as &$value) { if ($countTrap0 != $counting) { $drop .= "'". $value . "',"; } else { $drop .= "'". $value . "'"; } $counting++; } $drop .= "]);\n"; } elseif (isset($dropdown)) { //dropdown= $drop = "$('#stockrm').multipleSelect(\"uncheckAll\")"; } else { // $drop = "$('#stockrm').multipleSelect(\"checkAll\")"; } echo "<script>\n"; echo "$(function() {\n"; echo "".$drop.""; echo "});\n"; echo "$(\"#stockrm\").multipleSelect({ onClose: function() { document.getElementById('search').click(); }});\n"; echo "$(\"#stockrm\").multipleSelect();\n"; echo "</script>"; //close the database base_closeDatabase(); }add stockroom function //This function is use to add new stock room //code = stock room code //name = stock room name //desc = stock room description //remark = stock room remark //cat = stock room category function einv_addStockrm($code,$name,$desc,$remark,$cat) { //connect to database base_connectDatabase(); $User = base_getUserDetail($_SESSION['uID']); base_executeSQL("INSERT INTO einv_stockroom (einv_stockrm_code, einv_stockrm_name, einv_stockrm_desc, einv_stockrm_remark, einv_stockrm_cat) VALUES ('" . $code . "', '" . $name . "', '" . $desc . "', '" . $remark . "', '" . $cat . "')"); base_addTransactionLog('Manage Stock Room', 'Add', " Stock Room Code = " . $code . " || Stock Room Name = " . $name . " || Stock Room Description = " . $desc . " || Stock Room Remark = " . $remark . " || Stock Room Category = " . $cat . " "); //go to stock room page echo '<script type="text/javascript">' . "\n"; echo 'window.location="../einventory/stockrm_list.php";'; echo '</script>'; //close the database base_closeDatabase(); } Edit stockroom function einv_editStockrm($srid,$code,$name,$desc,$remark,$cat) { //connect to database base_connectDatabase(); $User = base_getUserDetail($_SESSION['uID']); $Stockroom = einv_getStockrmDetail($srid); base_executeSQL("UPDATE einv_stockroom SET einv_stockrm_code='" . $code . "', einv_stockrm_name='" . $name . "', einv_stockrm_desc='" . $desc . "', einv_stockrm_remark='" . $remark . "', einv_stockrm_cat = '" . $cat . "' WHERE einv_stockrm_id=" . $srid . ""); base_addTransactionLog('Manage Stock Room', 'Edit', " Stock Room Code = " . $code . " || Stock Room Name = " . $name . " || Stock Room Description = " . $desc . " || Stock Room Remark = " . $remark . " || Stock Room Category = " . $cat . " "); //go to stock room page echo '<script type="text/javascript">' . "\n"; echo 'window.location="../einventory/view_stockrm.php?id='. $srid .'";'; echo '</script>'; //close the database base_closeDatabase(); } I have a dropdown list named **Stockroom** where it displays an array of values. Example: **Stockroom** 1. [A] 2. [b] 3. [C] When user clicks on [A], it will display relevant data fields that [A] possess (appears below stockroom ddl). And as user clicks on [b], there is an onchange function that will then show [b] data fields (fields in A is deleted and replaced with B). I am able to add the initial values however, as i want to edit and change the stockroom from [A] to [b] which will result in a whole new data to be stored, i am unable to do so. Any ideas? I believe i have to amend my edit stockroom function where i require a set of coding such as If the array is selected, i have to delete existing data and add new data in accordance to the selected ID. Edited by mac_gyver, 14 January 2015 - 07:05 AM. code tags around posted code please The Script:
<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>"> <input type="text" name="hashtags" /> <input type="submit" name="submit" /> </form> <?php include("connect.php"); ?> <?php if(isset($_POST['submit'])){ $hashtags = explode(", ", $_POST['hashtags']); for($i= 0; $i < count($hashtags); $i++){ $tqs = "SELECT `id` FROM `hashtags_two` WHERE `hashtags` = '" . $hashtags[$i] . "'"; $tqr = mysqli_query($dbc, $tqs) or die(mysqli_error($dbc)); } $fetch_array = array(); while($row = mysqli_fetch_array($tqr)){ $fetch_array[] = $row['id']; } }Hey, sorry for these fundamental array questions lately, I am not going to ask much more when it comes to this. The hashtags come from the submit form (separated by commas) and get stored inside an array with the "explode()" function. The script should select the ID numbers of the hashtags from the table. With the script above only the last row gets inserted into $fetch_array inside the while loop. When the $fetch_array variable is printed on screen then only one ID number can be seen inside the array: Array ( [0] => 24 )How can I have the other ID numbers too? Hi, 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 people I need a way to loop through an array where $imgid is some random number assigned to each array element and there are 4 fields id, url, tnurl, caption per array element. I need to extract these 4 fields in the same loop iteration. Thanks Code: [Select] $_SESSION['imagegallery'][$imgid]['id']; $_SESSION['imagegallery'][$imgid]['url']; $_SESSION['imagegallery'][$imgid]['tnurl']; $_SESSION['imagegallery'][$imgid]['caption']; example: Code: [Select] $_SESSION['imagegallery'][347]['id']; $_SESSION['imagegallery'][347]['url']; $_SESSION['imagegallery'][347]['tnurl']; $_SESSION['imagegallery'][347]['caption']; $_SESSION['imagegallery'][892]['id']; $_SESSION['imagegallery'][892]['url']; $_SESSION['imagegallery'][892]['tnurl']; $_SESSION['imagegallery'][892]['caption']; Hello, this is my first post here.
I am trying to output the rows of a certain query in sequence after a POST has been requested.
I have been successful in getting the output in a pure php file but when I try to implement this in a web page with html/css, I can't echo the array in arbitrary locations after the post has processed.
This is the code which outputs successfully in a pure php file, but I need it to work in a <textarea> field as the results of a search
$rows2 = array(); $rows3 = array(); while($stmt->fetch()){ $rows2[] = $stratoparse; $rows3[] = $date; } $search = array(); for($i=0;$i<=$num_rows;$i++){ echo $rows3[$i].' '.$rows2[$i].'<br>'.'<br>'; } }To further iterate what I am asking. When errors are stored, you write something like $errors['username']="A username is required.";Then in any location of a webpage I can call this or show it, provided by this <?php isset($errors['username']) ? $errors['username']:" ");?>That is the same thing I am trying to do with this array which can be an arbitrary count of rows... I have not been successful in getting this to work... I have been told of string concatenation... I don't know what to do Thank you for any help Hi guys! I need some help with a code problem. I've a form with 2 inputs, one single and one multiline, and I need to pass the value of both into an array, var1 (single input) is the same for every line and var2 (multiline) change with every line Hoe can i do it? Hello phpfreaks I'm a bit new to PHP, as well as this forum. I'm learning in a fast way, but there's something I can't seem to figure out, nor find it on google. I'm sure it's a simple and basic trick, but like I said, I'm just a beginner So the question is: How can I store multiple words to an array, using only 1 input form field? I guess it's with a for-loop..? So everytime you hit the 'submit' button, a new word should be added to the array. My problem is that I'm always overwriting ONE word.. This is what I've got so far.. : Code: [Select] <?php if (isset($_POST['word'])){ $word = $_POST['word']; $word = strip_tags($word); $word = trim($word); $word = htmlentities($word); } else { $word = ""; } ?> <div id="arrays"> <p>Add a word to the array below:<br /><br /></p> <form action="index.php" method="post"> <input id="word" name="word" type="text" value="<?php echo $word; ?>" /> <br /><input class="btn" type="submit" value="Submit" /> </form> <br /> <p> <?php $array = array("apple", "banana", "lemon", $word); for ($i = 0; $i < count($array); $i++){ echo $array[$i] . " "; } ?> </p> </div> Also: I'm using PHP 5, in combination with xHTML strict 1.0. I want to make a table for each paddler_id (Field) which exists into pushup Database My code for paddler_id = 1 is require "../sql.php"; $result = mysql_query("EXPLAIN pushup"); $r = mysql_query("SELECT * FROM paddlerinfo t1 LEFT JOIN pushup t2 on t2.paddler_id=t1.id LEFT JOIN practicedate t3 on t3.practice=t2.practice_id ORDER BY t1.firstname ASC "); $r1 = mysql_query("SELECT * FROM pushup where paddler_id =1 ORDER BY practice_id ASC "); echo "<table width='30%' border='1' cellpadding='0' cellspacing='0' style='font-family: monospace'>"; echo "<tr>"; echo "<td>DATE</td>"; while ($row = mysql_fetch_array($result)) { if (in_array($row["Field"], array("paddler_id", "practice_id", "p_id"))) continue; echo "<td>",($row["Field"]), "</td>"; } echo "</tr>"; while (($data = mysql_fetch_array($r1, MYSQL_ASSOC)) !== FALSE) { unset($data["p_id"],$data["paddler_id"]); echo "<tr>"; foreach ($data as $k => $v) { echo "<td>"; echo"$v"; echo "</td>"; } echo "</tr>"; } echo "</table>"; mysql_free_result($result); mysql_free_result($r); mysql_free_result($r1); mysql_close(); The problem is on line $r1 = mysql_query("SELECT * FROM pushup where paddler_id =1 ORDER BY practice_id ASC "); I want to put something which makes it paddler_id = X where x = 2,3,4,5... and x exists in database and do not print twice the x (because that database may have rows where x = same id How do i do that?? Hi all Basically, I have a form which when done will calculate a quote for turf for given areas. Basically each time the user specifies an area it goes into an array, and they can add as many as they want, but the problem seems to be once submitted and it arrives back into the program, it isn't decoding so the multidimensional array is lost. What am I doing wrong here? Full code below, thanks in advance Ste Code: [Select] <?php // Framework // Get the sections $sections_array = base64_decode(unserialize($_POST['sections'])); // Build the rest of the array foreach ($sections_array as $section) { $sections[] = base64_decode(unserialize($section)); } // Set the initial unit $units = $_POST['units']; // Do the new add if ($_POST['a'] == 'add_section') { // Add the new measure if ((is_numeric($_POST['width'])) && (is_numeric($_POST['length']))) { $sections[] = array('length' => $_POST['length'], 'width' => $_POST['width']); } } // Build the output foreach ($sections as $section) { $output .= '<strong>'.$section['width'].' wide</strong> x <strong>'.$section['length'].' long</strong><br />'; $sections_array = base64_encode(serialize($section)); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <style type="text/css"> body,td,th { font-family: Verdana, Geneva, sans-serif; font-size: 11px; } body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } .wrap { text-align: center; height: 350px; width: 410px; padding: 0 10px; } </style> </head> <body> <div class="wrap"> <h2>Turf Calculator</h2> <p>To begin, enter the width and length of the first area of garden you wish to turf. You can keep adding sections to work out the final quantity required.</p> <p><?php echo $output; ?></p> <form id="form1" name="form1" method="post" action=""> <table width="0" border="0" cellspacing="0" cellpadding="2"> <tr> <td>Length:</td> <td><input type="text" name="length" id="length" /></td> </tr> <tr> <td>Width:</td> <td><input type="text" name="width" id="width" /></td> </tr> <?php if ($units == '') { ?> <tr> <td>Units:</td> <td><select name="units" id="units"> <option value="feet">Feet</option> <option value="m" selected="selected">Metres</option> <option value="yards">Yards</option> </select></td> </tr> <?php } ?> </table> <p> <input type="submit" name="add" id="add" value="Add This Section" /> <input name="a" type="hidden" id="a" value="add_section" /> <input name="sections" type="hidden" id="sections" value="<?php echo base64_encode(serialize($sections_array)); ?>" /> <?php if ($units != '') { ?> <input name="units" type="hidden" id="units" value="<?php echo $units; ?>" /> <?php } ?> </p> </form> <p> </p> </div> </body> </html> |