Jump to content

merylvingien

Members
  • Posts

    267
  • Joined

  • Last visited

Everything posted by merylvingien

  1. Hi guys, I have this code: if(isset($_POST['selected'])) { foreach($_POST['selected'] as $item) { $sql = "SELECT * FROM tablename WHERE ID=$item"; mysql_query($sql) or trigger_error("SQL: $sql, ERROR: " . mysql_error(), E_USER_ERROR); $result = mysql_query($sql); $num_rows = mysql_num_rows($result); if ($num_rows>6) { echo ("Too many checkboxes were selected"); } else while ($db_field = mysql_fetch_assoc($result)) { echo "stuff that is ok if number of checkboxes is correct"; } } } I am trying to limit the number of checkboxes that were selected, to say a max of 6. If the user selected any more than 6 a message should appear saying too many checkboxes were selected. Can anyone see where i went wrong? Cheers for any help fellas...
  2. Solved it myself. <input name='signupID[]' type='hidden' value='value' />
  3. Thanks for the reply smerny! Hmmm on a previous page i have multiple checkboxes all with the same name = "selected" and use this code: if(isset($_POST['selected'])) { foreach($_POST['selected'] as $item) { $sql = "SELECT * FROM Postcode WHERE postcodeID=$item"; mysql_query($sql) or trigger_error("SQL: $sql, ERROR: " . mysql_error(), E_USER_ERROR); $result = mysql_query($sql); some echo statments This works fine! Anyway, so i have to name the hidden fields individually? the trouble is that the amount of fields varies depending on what the user selected...
  4. Hi fellas, need a little help here. I have a page that has hidden values in a form. example <input name='signupID' type='hidden' value='1' /> <input name='signupID' type='hidden' value='2' /> <input name='signupID' type='hidden' value='3' /> <input name='signupID' type='hidden' value='4' /> also within this form, the user enters details, name, phone number etc. On the next page i need these hidden values to compare to the ID in the database so i can update the rows based on this hidden value. I have obviously taken a wrong route here becuase i am getting warning after warning. The code i have tried is this: if(isset($_POST['signupID'])) { foreach($_POST['signupID'] as $item) { echo "<input name='signupID' type='hidden' value='". $item . "' />"; but i get this: Warning: Invalid argument supplied for foreach() in C:\www\wasp-control.co.uk\ on line 79 The idea is that once the user has filled in the form, hits submit, next page compares the database to these hidden values "1,2,3,4" and then updates the database where the ID in the database is "1,2,3,4" Any help here would be great
  5. <?php if (isset($_POST['username']) { echo "fsaf"; } else { echo "<form name="login" method="post" action="index.php">"; echo "<input name="username" type="text" id="username">"; echo "<font color='#A4A4A4'><h3><center><bold>PASSWORD</bold></center></h3></font>"; echo "<input name="password" type="password" id="password"><br>"; echo "<center><input type="submit" name="Submit" value="Login"></form></center>"; } ?>
  6. Here is a start for you, you can see how its going and make the rest up from here. html: <!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> <link rel="stylesheet" type="text/css" href="test.css" /> </head> <body> <div id="main"> <div id="sidebar"> <ul> <li>France Boots</li> <li>Woman Casual</li> <li>Woman High Hills</li> <li>Woman Conservative</li> </ul> </div> <div id="container"> <h1>French Shoes Design</h1> <div class="shoeinfo"> <h2>French Sole Visa</h2> <img class="line" src="images/videoplayer.jpg" alt="videoplayer" width="500"> <h3> Rate:</h3> <h3>Prosedimiento</h3> <p>Women’s fashion shoes with higher heels generally have pre-made, thin, flexible, leather or resin rubber fitted soles, made using the bottom pattern created from the last. Two shapes of sole are made this way, one for a Louis heel, and the other for a Knock-on type. </p> <link label="More" /> </div> </div> </div> </div> </body> </html> css: /* CSS Document */ body { background: #fff; line-height: 1.6em; margin-top: 0; margin-bottom: 0; } div#main { background:#fff; height:auto; margin:auto; position:relative; width:980px; text-align: center; } div#container { width:980px; margin-left:240px; } div#sidebar { float:left; width:220px; padding: 5px; background: #669999; height: 300px; } .shoeinfo { width: 200px; height } .shoeinfo h2 {font-size:18px; color:#fff; background: #cc6600; text-align: left} .shoeinfo h3 {font-size:16px; color:#333333; text-align: left } .shoeinfo p {font-size: 11px;}
  7. Why not use php for the date? $today = date('d-m-y');
  8. Doh! Idiot prize of the evening goes to me Thanks Crayon Violent Working like a charm
  9. Thanks Andy, still no fix. Still displays last row price only This has to be something really simple that is escaping me..
  10. Thanks for the reply, but i tried that and the result is then the total only equals the last row from the database. so for example: bla bla bla 1 = £20.00 bla bla bla 2 = £15.00 bla bla bla 3 = £10.00 total = £10.00
  11. Hey guys, i hope someone can help me out here. I almost have this code sorted. <?php if(isset($_POST['selected'])) { foreach($_POST['selected'] as $item) { $sql = "SELECT * FROM Postcode WHERE postcodeID=$item"; mysql_query($sql) or trigger_error("SQL: $sql, ERROR: " . mysql_error(), E_USER_ERROR); $result = mysql_query($sql); while ($db_field = mysql_fetch_assoc($result)) { $total += $db_field['priceb']; print "<div class='redisplay'>" . $db_field['postcodename']. ", ". $db_field['town']. " <a href='#'>Towns Covered<span> {$db_field['stowns']}</span></a> ". $db_field['county']. ", ". $db_field['country']. " £". $db_field['priceb']. "</div> <br />"; } } } print " Total = £$total <br />"; mysql_close($con); ?> The total adds up ok, but i am getting a Notice message stating:Undefined variable: total on line 96 Which is this part: $total += $db_field['priceb']; I know i am missing something here Anyone see where i am wrong?
  12. Can anyone help me out with this code? Its only displaying the last price total when it should be adding all the prices up to give a final total, ive tried allsorts to get it to work but i cant figure it out. <?php if(isset($_POST['selected'])) { foreach($_POST['selected'] as $item) { $sql = "SELECT * FROM Postcode WHERE postcodeID=$item"; mysql_query($sql) or trigger_error("SQL: $sql, ERROR: " . mysql_error(), E_USER_ERROR); $result = mysql_query($sql); $total = 0; while ($db_field = mysql_fetch_assoc($result)) { print "<div class='redisplay'>" . $db_field['postcodename']. ", ". $db_field['town']. " <a href='#'>Towns Covered<span> {$db_field['stowns']}</span></a> ". $db_field['county']. ", ". $db_field['country']. " £". $db_field['priceb']. "</div> <br />"; $total += $db_field['priceb']; } } } print " Total = £$total <br />"; mysql_close($con); ?>
  13. Ok next question, will be the last for today i promise Ive got my results showing up now as expected, But i have a price for each one. Now to the realy dim part of the question, how do i add these prices up and have a total at the bottom?
  14. Righto, got it working. MANY MANY MANY thanks goes to cags God i am thick at this...
  15. WOW thanks for the fast reply, i am getting a bit of an error with that code. Fatal error: SQL: SELECT * FROM table WHERE id=x LIMIT 1, ERROR: Unknown column 'x' in 'where clause' in C:\Program Files\EasyPHP5.3.0\www\file\code7.php on line 94 Cant understand why its saying that, cause its just pulled column x from the database LOL Whats the limit1 about?
  16. Hi guys, been floating about here for the last few days reading and learning, but i could really do with some help here. I have a page with a list of results from my database, each result has a checkbox next to it with a value. When a user selects a checkbox or several checkboxes i need to then pass those values to the next page and check the database for matches against those values. Lets say for arguments sake that the values are 1, 5, 10 , 35 They could be ID's. I need to check if 1, 5, 10, 35 exist in the databse and if they do i need to return the rows of data on the page. For example: you have selected id 1, bla bla bla id 5, bla bla bla id 10, bla bla bla id 35, bla bla bla and so on. I have a little more to ask after i get this sorted, but not too much Any help here would be great. P.s this forum is great, so many people willing to help out, much better than the last i visited
×
×
  • 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.