Jump to content

slanton

Members
  • Posts

    27
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://

Profile Information

  • Gender
    Not Telling
  • Location
    New Zealand

slanton's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Using GROUP BY will only return me 3 rows without all the columns eg Paul cat Mark cat
  2. Say I had a table like Fred dog Paul cat Mark cat Fred fish Paul dog and used a query like //$query = "SELECT name, pet FROM clients"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ extract($row); echo $name; echo $pet; } I would get each row as Fred dog, Paul cat, Mark cat Fred fish Paul dog What I am trying to get is an array for each name something like Fred dog fish, Paul cat dog, Mark cat. I can't figure it out! Anyone?
  3. Well yes that does work but that is pretty much what I have already except I want to also allow a space, a hyphen and an apostrophe so I use !ereg("^[A-Za-z' -]{1,30}$",$firstName)) My reading of that is that it would allow uppercase and lowercase letters spaces, hyphens and apostrophes. But it also allows the use of & ...and once the & is used it allows the use of < and / etc.If I don't use the & it doesn't allow < or/. So my question really is why dose the above expression allow the use of & and how can I exclude it?
  4. Thanks but that doesn't work. I would also like to understand why the ereg functions like that.
  5. Instead of putting die('You did not complete all of the required fields'); you could put $error_message='You did not complete all of the required fields'; and the echo $error_message where ever you want. Is that what you mean?
  6. I am using this to validate ...elseif ($firstName==""or !ereg("^[A-Za-z' -]{1,30}$",$firstName)){ $message = "Please enter a valid Name"; } and if I enter a name and then a tag it catches the error eg "Frank</" is not allowed. But if I enter "Frank&</" it doesn't catch the error although the data is entered into the database as "Frank" which is weird. Why does it do that?
  7. Just to complicate it even further some places have a base rate per room for 2 people eg $100 and then an additional fee per extra person eg $20. So if you have 2 rooms and 5 people...4 people in one room and 1 in the other costs Room 1 Room2 base rate = $100 base rate = $100 2 extra = $40 Total = $140 For 2 rooms $240 which is more expensive than having 3 in one room and 2 in the other Room 1 Room 2 base rate = $100 base rate = $100 1 extra = $20 Total = $120 For 2 rooms $220 So to be fair the room assignment has to be the cheapest option. My head is starting to hurt.
  8. Yes I think you are right. The business constraints are fairly general in any accommodation. Each room only sleeps a certain number of people and if the number of people is more that that they need to book another room. All I am really trying to do is not double up on the number of people.
  9. Thanks for your input Frost110 If a room has 4 beds it can only hold 4 people so if there are 6 people they need two rooms. That situation is not so difficult. eg 2 adults and 4 kids ...2/2 and 4/2 =1 adult and 2 kids in each room. The real problem arises when there is 1 adult and 5 kids...1/2 and 5/2 =.5 adults and 2.5 kids in each room!! Somehow from that I have to get 1 adult and 2 kids in the first room and 0 adults and 3 kids in the second room. I tried your code but got a timeout from an endless loop or something. pplnet I am working through your code ..but I can't follow it.
  10. Yes I do. If the room has 4 beds and there are 6 people they need two rooms and I need to be able to put 3 in each rather than 4 and 2 as it is more cost effective.
  11. Hi Barry No I can't do that. I am working on a complicated little function that I hope will sort it.
  12. Like this? <?php $test ="Hullo"; ?> <script> var greeting ="<?php echo $test; ?>"; alert(greeting); </script>
  13. If I have the following problem. $adults=$_POST['adults'];//lets say its 2 $children=$_POST['children'];//lets say its 3 $rooms =array('101','102'); foreach($rooms as $roomnumber){ $insertSQL = "INSERT INTO bookings (roomNumber, adults, children) VALUES ( '$roomnumber', '$adults', '$children')"; $Result1 = mysql_query($insertSQL) or die(mysql_error()); } This works BUT..each room gets (say) 2 adults and 3 children whereas I want the numbers spread over each room so that room 101 gets maybe 2 people and room 102 gets 3 people or vice versa and not double -up on the number of overall people. In a real life situation the user would choose the number of rooms and adults etc so the solution would need to allow for this. Can anyone see a way of doing this?
×
×
  • 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.