PHP - How To Make Sure Minimum Qty Has Been Selected
I'm working on a little shopping cart and my issue is this....
Some of the products available have a minimum quantity that must be reached before they can add it to the cart. I have a field in the products table called "minimum". When the admin adds a new product, he inputs the minimum required to order the item. I need help figuring out how to write the code that checks to make sure the quantity entered meets the minimum quantity set in the products table. My code is below: Code: [Select] <?php session_start(); require("db.php"); require("functions.php"); $validid = pf_validate_number($_GET['id'], "redirect", $config_basedir); $prodsql = "SELECT * FROM products WHERE id = " . $_GET['id'] . ";"; $prodres = mysql_query($prodsql); $numrows = mysql_num_rows($prodres); $prodrow = mysql_fetch_assoc($prodres); $prodcatsql = "SELECT * FROM categories WHERE id = " . $_GET['id'] . ";"; $prodcatres = mysql_query($prodcatsql); $bulkcat = mysql_num_rows($prodcatres); if($numrows == 0) { header("Location: " . $config_basedir); } else { if($_POST['submit']) { if(!$_SESSION['SESS_ORDERNUM']) { if($_SESSION['SESS_LOGGEDIN']) { $sql = "INSERT INTO orders(customer_id, registered, date) VALUES(" . $_SESSION['SESS_USERID'] . ", 1, NOW())"; mysql_query($sql); session_register("SESS_ORDERNUM"); $_SESSION['SESS_ORDERNUM'] = mysql_insert_id(); } else { $sql = "INSERT INTO orders(registered, date, session) VALUES(0, NOW(), '" . session_id() . "')"; mysql_query($sql); session_register("SESS_ORDERNUM"); $_SESSION['SESS_ORDERNUM'] = mysql_insert_id(); } } foreach ($_POST as $name => $value) { if (substr($name, 0, 4) == 'qty_' && $value != '' && is_numeric($value)) { $arrOptions = explode('_', $name); $sizeid = $arrOptions[1]; $colorid = $arrOptions[2]; $quantity = $value; $itemsql = "INSERT INTO orderitems(order_id, product_id, size_id, color_id, quantity) VALUES (" . $_SESSION['SESS_ORDERNUM'] . ", " . $_GET['id'] . ", " . $sizeid . ", " . $colorid . ", " . $quantity . ")"; mysql_query($itemsql); } } $totalprice = $prodrow['price'] * $_POST['amountBox'] ; $updsql = "UPDATE orders SET total = total + " . $totalprice . " WHERE id = " . $_SESSION['SESS_ORDERNUM'] . ";"; mysql_query($updres); header("Location: " . $config_basedir . "showcart.php"); } else { require("header.php"); echo "<div id='adminhome'>"; echo "<form action='addtobasket.php?id=" . $_GET['id'] . "' method='POST'>"; echo "<table cellpadding='10' border='0'>"; echo "<tr>"; if(empty($prodrow['image'])) { echo "<td width='205'><img src='store-images/no-image-large.jpg' width='200' alt='" . $prodrow['name'] . "'>"; } else { echo "<td width='205'> <img src='store-images/" . $prodrow['image'] . "' width='200' alt='" . $prodrow['name'] . "'>"; } echo "</td>"; echo "<td>"; echo "<h1>";echo $prodrow['name'];echo "</h1>"; echo "<h2>";echo $prodrow['description'];echo "</h2>"; //echo "<pre>" . wordwrap( $prodrow['description'] , 30 ) . "</pre>"; echo "<p>";echo $prodrow['details'];echo "</p>"; echo "<br>"; if($bulkcat==0) { echo "<div id='bulk1'>"; echo "<table cellpadding='2' border='0'>"; echo "<tr>"; echo "<td>Quantity</td>"; echo "<td>12</td>"; echo "<td>24+</td>"; echo "<td>48+</td>"; echo "</tr>"; echo "<tr>"; echo "<td>Price</td>"; echo "<td>$" . money_format('%i', $prodrow['price']) . "</td>"; echo "<td>$" . money_format('%i', $prodrow['price2']) . "</td>"; echo "<td>$" . money_format('%i', $prodrow['price3']) . "</td>"; echo "</tr>"; echo "</table>"; echo "</div>"; echo "<div id='bulk2'>"; echo "<table cellpadding='2' border='0'>"; echo "<tr>"; echo "<br><div align='center'><strong>For Sizes 2XL - 5XL</strong></div>"; echo "</tr>"; echo "<tr>"; echo "<td>Quantity</td>"; echo "<td>12</td>"; echo "<td>24+</td>"; echo "<td>48+</td>"; echo "</tr>"; echo "<tr>"; echo "<td>Price</td>"; echo "<td>$" . money_format('%i', $prodrow['price4']) . "</td>"; echo "<td>$" . money_format('%i', $prodrow['price5']) . "</td>"; echo "<td>$" . money_format('%i', $prodrow['price6']) . "</td>"; echo "</tr>"; echo "</table>"; echo "</div>"; } else { echo "<div id='bulk1'>"; echo "<table cellpadding='2' border='0'>"; echo "<tr>"; echo "<td>Quantity</td>"; echo "<td>12</td>"; echo "<td>24+</td>"; echo "<td>48+</td>"; echo "</tr>"; echo "<tr>"; echo "<td>Price</td>"; echo "<td>$" . money_format('%i', $prodrow['price']) . "</td>"; echo "<td>$" . money_format('%i', $prodrow['price2']) . "</td>"; echo "<td>$" . money_format('%i', $prodrow['price3']) . "</td>"; echo "</tr>"; echo "</table>"; echo "</div>"; } echo "</td>"; echo "</tr>"; echo "</table>"; echo '<div id="basketmatrix">'; echo '<table cellpadding="1" border="1">'; echo '<tr>'; echo '<td></td>'; $arrsizes = array(); $i = 0; $result = mysql_query("SELECT DISTINCT s.id, s.size FROM sizes s INNER JOIN productoptions p ON s.id = p.sizeid WHERE p.productid = '" . $_GET['id'] . "' ORDER BY s.id"); while ($row = mysql_fetch_assoc($result)) { echo '<td class="heading">' . $row['size'] . '</td>'; $arrsizes[$i] = $row['id']; $i++; } echo '</tr>'; $i = 0; $result = mysql_query("SELECT DISTINCT c.id, c.color FROM colors c INNER JOIN productoptions p ON c.id = p.colorid WHERE p.productid = '" . $_GET['id'] . "' ORDER BY c.id"); while ($row = mysql_fetch_assoc($result)) { echo '<tr>'; echo '<td class="heading">' . $row['color'] . '</td>'; foreach ($arrsizes as $sizevalue) { echo '<td><input type="text" name="qty_' . $sizevalue . '_' . $row['id'] . '" size="5" /></td>'; } echo '</tr>'; } echo '</table>'; echo '</div>'; echo "<br>"; echo "<br>"; echo '<table>'; echo '<tr>'; echo '<td>'; echo '<p>You MUST order a total of <font color="#ff0000"><strong>(' . $prodrow['minimum'] . ')</strong></font> or more to add this item to your cart.<br>'; echo '(all colors + all sizes = total)</p>'; echo '</td>'; echo '<tr>'; echo '<td>'; echo"<input type='submit' name='submit' value='Add To Cart'>"; echo '</td>'; echo '</tr>'; echo '</table>'; echo "</form>"; echo "</div>"; } } require("footer.php"); ?> Similar TutorialsHi all.
how can i make the values show like a list. I tried html line break "<br>" and php \n but all to no avail. It just show all the values in one straigth line.
example of what i want is for the values to appear like this:
1234567890
0987654345
4567890675
instead of :
1234567890 0987654345 4567890675
Thanks
<form data-abide method="post" action=""> <div> <select name=""> <option value="name"> <?php $stmt = $pdo->query("SELECT acct_num FROM table order by id desc"); while ( $row = $stmt->fetch(PDO::FETCH_ASSOC) ) { echo $row['acct_num']; } ?> </option> </select> </div> <div> <label>New Password <small>required</small></label> <input type="password" name="password" id="password" required> <small class="error">New password is required and must be a string.</small> </div> <div> <label>Confirm New Password <small>required</small></label> <input type="password" name="password2" id="password2" required> <small class="error">Password must match.</small> </div> <input name="submit" type="submit" class="button small" value="Change Password"> </form> Edited by Mr-Chidi, 13 November 2014 - 01:34 AM. Hi i need a bit of help. i have toner database which stores, the type, brand, colour, min, max stock. I just want to know if there is anyway of notifying the user when the toner reachs the min level, maybe highligh the row in red or something similar. many thanks. Here's the scenario.... A Customer clicks on a product on the product page, this will open up the page for the individual product. In this example, it's a shirt. The shirt is available in many sizes and colors. The Minimum QTY for this product is : 12 . The customer can select as many sizes and colors as they want, as long they select a total of 12 (all sizes + all colors = total). After making their selections for this shirt, there is an "Add to Cart" button. I would like to run a check to make sure that the total is equal to or greater than the minimum QTY. Here is the form : Code: [Select] <?php session_start(); require("db.php"); require("functions.php"); $validid = pf_validate_number($_GET['id'], "redirect", $config_basedir); $prodsql = "SELECT * FROM products WHERE id = " . $_GET['id'] . ";"; $prodres = mysql_query($prodsql); $numrows = mysql_num_rows($prodres); $prodrow = mysql_fetch_assoc($prodres); $prodcatsql = "SELECT * FROM categories WHERE id = " . $_GET['id'] . ";"; $prodcatres = mysql_query($prodcatsql); $bulkcat = mysql_num_rows($prodcatres); if($numrows == 0) { header("Location: " . $config_basedir); } else { if($_POST['submit']) { if(!$_SESSION['SESS_ORDERNUM']) { if($_SESSION['SESS_LOGGEDIN']) { $sql = "INSERT INTO orders(customer_id, registered, date) VALUES(" . $_SESSION['SESS_USERID'] . ", 1, NOW())"; mysql_query($sql); session_register("SESS_ORDERNUM"); $_SESSION['SESS_ORDERNUM'] = mysql_insert_id(); } else { $sql = "INSERT INTO orders(registered, date, session) VALUES(0, NOW(), '" . session_id() . "')"; mysql_query($sql); session_register("SESS_ORDERNUM"); $_SESSION['SESS_ORDERNUM'] = mysql_insert_id(); } } foreach ($_POST as $name => $value) { if (substr($name, 0, 4) == 'qty_' && $value != '' && is_numeric($value)) { $arrOptions = explode('_', $name); $sizeid = $arrOptions[1]; $colorid = $arrOptions[2]; $quantity = $value; $itemsql = "INSERT INTO orderitems(order_id, product_id, size_id, color_id, quantity) VALUES (" . $_SESSION['SESS_ORDERNUM'] . ", " . $_GET['id'] . ", " . $sizeid . ", " . $colorid . ", " . $quantity . ")"; mysql_query($itemsql); } } $totalprice = $prodrow['price'] * $_POST['amountBox'] ; $updsql = "UPDATE orders SET total = total + " . $totalprice . " WHERE id = " . $_SESSION['SESS_ORDERNUM'] . ";"; mysql_query($updres); header("Location: " . $config_basedir . "showcart.php"); } else { require("header.php"); echo "<div id='adminhome'>"; echo "<form action='addtobasket.php?id=" . $_GET['id'] . "' method='POST'>"; echo "<table cellpadding='10' border='0'>"; echo "<tr>"; if(empty($prodrow['image2'])) { echo "<td width='205'><img src='store-images/no-image-large.jpg' width='200' alt='" . $prodrow['name'] . "'>"; } else { echo "<td width='205'> <img src='store-images/" . $prodrow['image2'] . "' width='200' alt='" . $prodrow['name'] . "'>"; } echo "</td>"; echo "<td>"; echo "<h1>";echo $prodrow['name'];echo "</h1>"; echo "<h2>";echo $prodrow['description'];echo "</h2>"; //echo "<pre>" . wordwrap( $prodrow['description'] , 30 ) . "</pre>"; echo "<p>";echo $prodrow['details'];echo "</p>"; echo "<br>"; if($bulkcat==0) { echo "<div id='bulk1'>"; echo "<table cellpadding='2' border='0'>"; echo "<tr>"; echo "<td>Quantity</td>"; echo "<td>12</td>"; echo "<td>24+</td>"; echo "<td>48+</td>"; echo "</tr>"; echo "<tr>"; echo "<td>Price</td>"; echo "<td>$" . money_format('%i', $prodrow['price']) . "</td>"; echo "<td>$" . money_format('%i', $prodrow['price2']) . "</td>"; echo "<td>$" . money_format('%i', $prodrow['price3']) . "</td>"; echo "</tr>"; echo "</table>"; echo "</div>"; echo "<div id='bulk2'>"; echo "<table cellpadding='2' border='0'>"; echo "<tr>"; echo "<br><div align='center'><strong>For Sizes 2XL - 5XL</strong></div>"; echo "</tr>"; echo "<tr>"; echo "<td>Quantity</td>"; echo "<td>12</td>"; echo "<td>24+</td>"; echo "<td>48+</td>"; echo "</tr>"; echo "<tr>"; echo "<td>Price</td>"; echo "<td>$" . money_format('%i', $prodrow['price4']) . "</td>"; echo "<td>$" . money_format('%i', $prodrow['price5']) . "</td>"; echo "<td>$" . money_format('%i', $prodrow['price6']) . "</td>"; echo "</tr>"; echo "</table>"; echo "</div>"; } else { echo "<div id='bulk1'>"; echo "<table cellpadding='2' border='0'>"; echo "<tr>"; echo "<td>Quantity</td>"; echo "<td>12</td>"; echo "<td>24+</td>"; echo "<td>48+</td>"; echo "</tr>"; echo "<tr>"; echo "<td>Price</td>"; echo "<td>$" . money_format('%i', $prodrow['price']) . "</td>"; echo "<td>$" . money_format('%i', $prodrow['price2']) . "</td>"; echo "<td>$" . money_format('%i', $prodrow['price3']) . "</td>"; echo "</tr>"; echo "</table>"; echo "</div>"; } echo "</td>"; echo "</tr>"; echo "</table>"; echo '<div id="basketmatrix">'; echo '<table cellpadding="1" border="1">'; echo '<tr>'; echo '<td></td>'; $arrsizes = array(); $i = 0; $result = mysql_query("SELECT DISTINCT s.id, s.size FROM sizes s INNER JOIN productoptions p ON s.id = p.sizeid WHERE p.productid = '" . $_GET['id'] . "' ORDER BY s.id"); while ($row = mysql_fetch_assoc($result)) { echo '<td class="heading">' . $row['size'] . '</td>'; $arrsizes[$i] = $row['id']; $i++; } echo '</tr>'; $i = 0; $result = mysql_query("SELECT DISTINCT c.id, c.color FROM colors c INNER JOIN productoptions p ON c.id = p.colorid WHERE p.productid = '" . $_GET['id'] . "' ORDER BY c.id"); while ($row = mysql_fetch_assoc($result)) { echo '<tr>'; echo '<td class="heading">' . $row['color'] . '</td>'; foreach ($arrsizes as $sizevalue) { echo '<td><input type="text" name="qty_' . $sizevalue . '_' . $row['id'] . '" size="5" /></td>'; } echo '</tr>'; } echo '</table>'; echo '</div>'; echo "<br>"; echo "<br>"; echo '<table>'; echo '<tr>'; echo '<td>'; echo '<p>You MUST order a total of <font color="#ff0000"><strong>(' . $prodrow['minimum'] . ')</strong></font> or more to add this item to your cart.<br>'; echo '(all colors + all sizes = total)</p>'; echo '</td>'; echo '<tr>'; echo '<td>'; echo"<input type='submit' name='submit' value='Add To Cart'>"; echo '</td>'; echo '</tr>'; echo '</table>'; echo "</form>"; echo "</div>"; } } require("footer.php"); ?> ok here is my code: it has a counter variable $i at the start which basically acts as a maximum cutoff for how much data can be output. i have this variable set at 5. how can i make it so that it doesnt cut off the results (outputs the full 7 days worth of results if available), but ALWAYS outputs a minimum of 5 results? $now = $now-(7*24*60*60); // Display 7 Days of Results $query = mysql_query("SELECT * FROM table WHERE date >= '$now' ORDER BY max(date) desc"); $i = 0; while ($row = mysql_fetch_assoc($query)) { $cid = $row['cat_id']; $title = $row['name']; $seoname = cleanurl($title,0); $img = 'images/'.$seoname.'.jpg'; if (!file_exists($img)) { $img = ''; } else { $img = 'images/'.$seoname.'.jpg'; } if (!empty($img)) { $i++; } if (!empty($img) && $i <= 5) { // Always show ATLEAST 5 results echo '<img src="'.$img .'" style="width:528px;" alt="" />' . "\n"; } } Please help and look at my code..thanks. I need help this problem seem too tricky for me right now. I got an array with decimal numbers and behind it says Yes/No. The min() function works magically and still is able to correctly give me the lowest value. But how do i make a while loop that loops until it pops a value that is lowest and has Yes behind it? For example: Array => ('11,64|No', '209,81|Yes', '533,42|Yes', '27,90|No', '93,01|Yes') So this function should return '93,01|Yes' i want make php script using minimum spanning tree algorithm, the start node is define from user input, and the end nodes are from database table. the distance is calculated between Start node (koord_x, koord_y) and end nodes (koord_x2, koord_y2). The output are the minimun distance, name start node and end node include distance between them. please help me, i'm working on my thesis... Hi Guys I am adding a short contact form to a site. All the fields are text fields. What do you think is the minimum validation I need to add to make the form safe against hacking etc. Thanks I have a comment section that is secure against everything except spam.. Is there anyway to do like a 10second minimum wait time between posts? I have this loop on a shorturl website i own that selects domains from my website and lists them in a dropdown list where users can select one domain to use as url shortener. The problem is that when a users selects and entry from the dropdown list this created only the [[[main_url]]] entry from the database table bellow can be used. When someone selectes "coolartistname.site.com the submit button cannot be pressed. in other words it's not adding the SELECTED attribute other than the [[[main_url]]] domain. Can anyone see on the code bellow why this would happen?
**Index.php** // get base urls $shortUrlDomains = getShortUrlDomains(); <?php foreach ($shortUrlDomains AS $k => $shortUrlDomain) { // active domains only if (($shortUrlDomain['premium_only'] !== '1') && ($shortUrlDomain['premium_only'] !== $Auth->id)) { continue; } echo '<option value="' . (int)$k . '"'; if (isset($_REQUEST['shortUrlDomain'])) { if ($k == (int)$_REQUEST['shortUrlDomain']) { echo 'SELECTED'; } } echo '>'; echo $shortUrlDomain['domain']; if ($disabled == true) { echo ' (' . safeOutputToScreen(t('unavailable', 'unavailable')) . ')'; } '</option>'; } echo '</optgroup>'; ?> FUNCTIONS.PHP function getShortUrlDomains() { // if we already have it cached if(defined('_SETTINGS_SHORT_URL_DOMAINS')) { return unserialize(_SETTINGS_SHORT_URL_DOMAINS); } // get connection $db = Database::getDatabase(true); // load from database $domains = $db->getRows("SELECT id, domain, premium_only, status FROM url_domain ORDER BY premium_only ASC, id ASC"); // organise and replace site url $rs = array(); foreach($domains AS $domain) { if($domain['domain'] == '[[[main_url]]]') { $domain['domain'] = _CONFIG_SITE_FULL_URL; } $rs[$domain{'id'}] = $domain; } **MYSQL DATABASE** url_domain (id, domain, premium_only, status, date_created, owner) VALUES (1, '[[[main_url]]]', 0, 'enabled', '2019-03-02 08:13:00', 1) (14, 'coolartistname.site.com', 6, 'enabled', '2020-04-18 19:21:59', 6);
Hi all, I have a html drop down menu and want to show the initially selected value as the one stored in the mysql database that a member selected. I have 180+ rows in mysql that a member could have selected and would like to basically do this: IF (value of option == $row['value'] ) { echo "selected=\"selected\"; } I could put this in every one of the rows it would be much better to have an if statement. As there are so many values I do not know where to begin. Can someone point me in the right direction? Thanks Okay so my news script is set to view only 10 pieces of news. But I want it so that it starts a new page once I have more than 10 pieces of news. Code: [Select] <?php require("functions.php"); include("dbconnect.php"); session_start(); head1(); body1(); new_temp(); sotw(); navbar(); $start = 0; $display = 10; $query = "SELECT * FROM news ORDER BY id DESC LIMIT $start, $display"; $result = mysql_query( $query ); if ($result) { while( $row = @mysql_fetch_array( $result, MYSQL_ASSOC ) ) { news_box( $row['news'], $row['title'], $row['user'], $row['date'], $row['id'] ); } mysql_free_result($result); } else { news_box( 'Could not retrieve news entries!', 'Error', 'Error', 'Error'); } footer(); mysql_close($link); ?> I tried a few things but they failed....miserably. How can I maintain selected='selected' when the page is reloaded? I don't want to just echo out what they have selected, but rather maintain which option has been selected. Here is my drop down. Code: [Select] <form method='POST' id='jumpbox' action='./entrepreneur.php' onsubmit='if(document.jumpbox.industry.value == -1){return false;}'> <fieldset class='jumpbox'> <select name='industry' id='industry' onchange='if(this.options[this.selectedIndex].value != -1){ document.forms['jumpbox'].submit() }'> <option value='-1' selected='selected'>Select an Industry</option> <option value='-1'>------------------</option> <option value='1'>Digital Media</option> <option value='2'>Software</option> <option value='3'>Telecommunication</option> </select> <input type='submit' value='Go' class='go'/> </fieldset> </form> Im having trouble deleting the selected checkboxes in my form. I have tried several options out there but none seem to work. here is the code i have which generates the checkboxes. i am alos using jquery to select all. <form name="checkboxes" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> This is within the while loop: echo "<input value=\"{$messages_info->message_id}\" style=\"float:left;\" type=\"checkbox\" name=\"checkbox\" />"; <a href="<?php echo $site_root; ?>/user_center.php?user=<?php echo $_GET['user']; ?>&do=messages&action=del_marked"> Delete Marked</a> </span> Anyone have any ideas? Thanks I have the following which fils a combo box with years from 1950 to 2100. This is the year box for the date of birth. Year <select name="year_select"> <?php for( $i=1950; $i<=2100; $i++ ) { echo "<option value=\"{$i}\" class=\"year\">{$i}</option>"; } ?> </select> I want it to automatically display the year that is in the database so instead of automatically displaying 1950 i want their birth year displayed which is $tab_info->user_dob_year. How would i go about this? i dont know where to start since im using a for loop to populate it. The rest of my coding works however this part does not and I'm trying to figure out why. I'm sure my syntax isn't right so I hope someone can correct my mistake. $contentpageID = $_GET['id']; $query = "SELECT contentpages.contentpage, contentpages.shortname, contentpages.contentcode, contentpages.linebreaks, contentpages.backlink, contentpages.showheading, contentpages.visible, contentpages.template_id FROM contentpages WHERE contentpages.id = '" . $contentpageID . "'"; <label for="template">Template</label> <select class="dropdown" name="template" id="template" title="Template"> <option value="0">- Select -</option> <?php $query = 'SELECT * FROM templates'; $result = mysql_query ( $query ); while ( $template_row = mysql_fetch_assoc ( $result ) ) { print "<option value=\"".$template_row['id']."\" "; if($template_row['id'] == $row['template_id']) { print " SELECTED"; } print ">".$template_row['templatename']."</option>\r"; } ?> </select> Hi How are you all, I will explain me issue one by one first of all I have created a mysql database ((ftest)) and it contain a table ((test1)) and that table contin a filed ((name)) In that filed I have 3 names 1- James 2- Moly 3- Cris let's start with the first file I have it's the config.php which will connect to the mysql database second we have index.php which contain Code: [Select] <?php /////////////////////////////////////////////////////////////////////////////// require_once "easytemplate.php"; $easy = new EasyTemplate(); $easy->Temp = 'template'; $easy->Cache = 'easycache'; include 'config.php'; /////////////////////////////////////////////////////////////////////////////// $e = mysql_query("select name from test1"); while ($row = mysql_fetch_array($e)) { extract($row); $name = $row ['name']; print $easy->display("html.tpl"); } ?> As you can see I'm defining Code: [Select] require_once "easytemplate.php"; which is a normal Template Engine anyway It will extract all the 3 names then it will call html.tpl which contain the html design code let's see what the html.tpl contain Code: [Select] <form action='main.php' method=post> <head> <meta http-equiv="Content-Language" content="en-us"> </head> <p><font color="#FF0000"><span style="background-color: #FFFFFF">{name}</span></font></p> <input type="checkbox" name="name" value="{name}"> <input type="submit" name="submit" value="submit" /> </form> No I will run the Index.php file to see how it looks with the template file (html.tpl) this is the snapshot from the browser What I want exactly if I did check more than one name for example Cris and Moly and then press any of the submit buttons I want the names ((Cris & Moly) to be printed in the next page which is main.php Code: [Select] <?php /////////////////////////////////////////////////////////////////////////////// include 'config.php'; /////////////////////////////////////////////////////////////////////////////// if(isset($_POST['name'])) $names = $_POST['name']; if ($_POST){ echo $names; } ?> Now It will work but it will print only one name thank you for your time Hi guys, im having a radio button which i need it to be checked if its status is equal to something. as an example i need to use the checkbox below checked if its field in mysql is equal to male <p>Male <input type="radio" name="male" value="Male"/> <br/> this is made for a profile page where users can insert their gneder, I know i have to return the value from myslq to check if its equal to radio button value, I can do select mysql_query from my db but how should i say if its match, check the radio button? can u please help me how to do it? I have a form with several text fields. For example (sorry, no code insert option on my phone) Quote<form method="post"> Enter value1 :<input type="text" name="str1"><br/> Enter value2 :<input type="text" name="str2"><br/> <input type="submit" > I would like to scan the INPUTS to determine which fields were left empty. Using !isset (to the best of my knowledge) would require that I list each input individually. Is there a PHP alternative that, similar to JavaScript, would allow me to evaluate every INPUT or TEXT field to then list those left empty? Hi I wanted to know how once I have selected and echoed the rows from mysql table how can I get it to number those rows that echo? etc 1. echo $variable 2. echo $variable 3. echo $variable 4. echo $variable 5. echo $variable Any help is appreciated Hi guys! I'm trying to make a <select> button for car positions which displays a set of numbers like 1-5 or 1-10 so on.. I need to remove the numbers that is already been selected. Selected numbers are stored in the database and i fetch them in a simple query then compared it to the max number of cars. I have this code, it kinda works but it shows the number 1 which is already been selected. Selected numbers are 1 and 3, it successfully removes number 3 but not 1, The output is 1,2,4,5,6,7,8,9,10 I added some comments for clarity.. Code: [Select] function position_available($event_id, $number_of_cars) // receives id for ref. in the database { $selected_positions = check_selected_positions($event_id); // query to get selected positions while($positions = mysql_fetch_array($selected_positions)) { $position = array(); array_push($position, $positions['car_position']); // 'car position' is the name of the field } for($i = 1; $i <= $number_of_cars; $i++) // $number_of_cars is the total number of cars { if(! in_array($i, $position)) echo "<option value='{$i}'>" . $i . "</option>"; } } Did i miss something simple? thanks for the help in advance! |