Jump to content

rn14

Members
  • Posts

    111
  • Joined

  • Last visited

    Never

Everything posted by rn14

  1. Thanks is there anyway of recovering it except from the webhosting company?
  2. I know this isnt directly related to php but i have spent the last couple of days working on part of a website and I have now overwritten the file on a shared web hosting server using ftp. Does anybody know if it is possible to get this back? Thanks
  3. Could anybody please help me with this??
  4. Hi, I have an application where the user selects a number of people that they want to buy the product for. Based on this number their is a checkbox next to each product. The customer is then presented with 7 products of which they must select 5. I have written some simple if statements so that when the user selects the number of people this limits the the number of check boxes to the amount of people they have selected. To be clear, that means i have seven products on a page and if there are 3 people buying the products that will mean a total of 21 checkboxes. 7 for each person. Each person must select 5. My problem is trying to validate this to limit each person to picking 5 products: Here is what i have tryed: <?php session_start(); $num_of_people = $_SESSION['numofpeople']; //meal for 1 if($num_of_people == 1) { if (count($_POST['meal']) == 5) { echo '<META HTTP-EQUIV="Refresh" Content="0; URL=our_menustestw2.php">'; } //meal for 2 }elseif ($num_of_people == 2) { if (count($_POST['meal']) == 5 || count($_POST['meal2']) == 5) { echo '<META HTTP-EQUIV="Refresh" Content="0; URL=our_menustestw2.php">'; } //meal for 3 }elseif ($num_of_people == 3) { if (count($_POST['meal']) == 5 || count($_POST['meal2']) == 5 || count($_POST['meal3']) == 5) { echo '<META HTTP-EQUIV="Refresh" Content="0; URL=our_menustestw2.php">'; } //meal for 4 }elseif ($num_of_people == 4) { if (count($_POST['meal']) == 5 || count($_POST['meal2']) == 5 || count($_POST['meal3']) == 5 || count($_POST['meal4']) == 5) { echo '<META HTTP-EQUIV="Refresh" Content="0; URL=our_menustestw2.php">'; } //meal for 5 }elseif ($num_of_people == 5) { if (count($_POST['meal']) == 5 || count($_POST['meal2']) == 5 || count($_POST['meal3']) == 5 || count($_POST['meal4']) == 5 || count($_POST['meal5']) == 5) { echo '<META HTTP-EQUIV="Refresh" Content="0; URL=our_menustestw2.php">'; } }else echo '<META HTTP-EQUIV="Refresh" Content="0; URL=our_menustest.php">'; ?> What happens above is that when a first person buying selects five products the validation does not work. Not sure if i explained this clearly. Thanks for any help
  5. Any chance of anybody having a look at this???
  6. I have 7 check boxes of which 5 and only 5 can be selected. These are printed in an array. These are my functions: <script type="text/javascript"> function checkArray(mainform, arrayName) { var retval = new Array(); for(var i=0; i < form.elements.length; i++) { var el = form.elements[i]; if(el.type == "checkbox" && el.name == arrayName && el.checked) { retval.push(el.value); } } return retval; } function checkForm(mainform) { var itemsChecked = checkArray(mainform, "meal[]"); alert("You selected " + itemsChecked.length + " items"); if(itemsChecked.length > 0) { alert("The items selected were:\n\t" + itemsChecked); } return false; } </script> This is the form that i use <form method="post" action = "our_menustestw2.php" name = "mainform" onsubmit="checkForm();" > <input type="checkbox" name="meal2[]" value="<?php echo $row['id']; ?>" CHECKED/> <input type="submit" value="Submit Changes" name = "b1"> Thanks in advance for any help
  7. Should this work???? <? if($rows <= 5) { echo'<p><input type="checkbox" name="meal[]" value="'.$row['id'].'" checked="checked"/>'; } else { echo'<p><input type="checkbox" name="meal[]" value="'.$row['id'].'" />'; } ?> Thanks
  8. Really tearing my hair out with this could anybody give me some help?? Thanks
  9. Its part of a while loop so will I be able to work it like that. I have to still print out the 7 checkboxes but just with 5 selected while($row = mysql_fetch_array($result)) { $image = $row['image']; $title = $row['title']; $description = $row['text']; echo strip_tags($image, '<img>, <span>'); ?> <p><input type="checkbox" name="meal[]" value="<?php echo $row['id']; ?>" CHECKED/> What you think??
  10. Hi, <p><input type="checkbox" name="meal[]" value="<?php echo $row['id']; ?>" CHECKED/> The above is printed out as part of a loop. there are 7 checkboxes printed out each one being checked. However i still want the seven printed out but with only the first 5 checked. Could anybody help me with this? Thanks
  11. Thanks for your help here. Got this working now.
  12. Yes thanks, does that mean that if I have multiple objects of order they can all be retrieved from the one session called order?
  13. Im fairly new to this so this might be stupid but can I put the two objects in one session? Did you mean use one one object but I amcollecting different data from multiple pages?
  14. They are both seperate and they are coming from different pages. Does this mean I will have to insert them into db??
  15. if these are two objects that i have in sesssions how will I add them to the session array?? if these are two objects that i have in sessions below How will I add them to the session array? session_start(); include('class.php'); if (isset($_SESSION['order'])) { $order = unserialize($_SESSION['order']); }else { $order = new Order(); } // incase we want to reset our test data. if ($_REQUEST['reset'] == "ok") { $order = new Order(); } $meallist = array(); foreach ($_REQUEST as $k=>$v) { if ($k=="meal") { $meallist = $v; } } $order->Test($meallist); //changed this to reference index of 0. $_SESSION['order'] = serialize($order); ?> <? //order +1 if (isset($_SESSION['orderp2'])) { $orderp2 = unserialize($_SESSION['orderp2']); }else { $orderp2 = new Order(); } // incase we want to reset our test data. if ($_REQUEST['reset'] == "ok") { $orderp2 = new Order(); } $meallist = array(); foreach ($_REQUEST as $k=>$v) { if ($k=="meal2") { $meallist = $v; } } $orderp2->Test($meallist); //changed this to reference index of 0. $_SESSION['orderp2'] = serialize($orderp2); ?> [code] Thanks
  16. Thanks, if i then have a number of objects and put all of them into sessions is it possible to retrieve these on one page? Or will I have to insert the sessions into a db?
  17. This is where create a new object and pass values to it. I know it fills this with values as when i print out the values on this page they display. include('class.php'); $order = new Order(); $meallist = array(); foreach ($_REQUEST as $k=>$v) { if ($k=="meal") { $meallist = $v; } } $order->Test($meallist); My problem occurs when i attempt to print these values out on a different page using the following code: <? include('class.php'); $array = $order->getData(); $meal1 = $array[0]; $meal2 = $array[1]; $meal3 = $array[2]; $meal4 = $array[3]; $meal5 = $array[4]; $meal6 = $array[5]; $meal7 = $array[6]; ?> I get this error: Fatal error: Call to a member function getData() on a non-object. Could anyone help? Thanks
  18. rn14

    sessions

    Im new to this but really need to be able to this. I dont really understand what you have explained how will I do that?
  19. rn14

    sessions

    Because i have multiple objects and I want to re-use them on a different page? Is this the correct way to do it?
  20. rn14

    sessions

    I have multiple objects each one is stored in a separate session. Below I am unseriliazing the sessions and passing the values from each object to variables and then using them in a db query. The problem is the values I return from the first object are used as the values through all of the object I return on this page. Should I be able to this?? Thanks <? session_start(); include('class.php'); $order = unserialize($_SESSION['order']); $array = $order->getData(); $meal1 = $array[0]; $meal2 = $array[1]; $meal3 = $array[2]; $meal4 = $array[3]; $meal5 = $array[4]; $meal6 = $array[5]; $meal7 = $array[6]; include('config.php'); $link=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD)or die("Could not connect: " . mysql_error()); mysql_select_db("_simp"); if (isset($meal1)){ $result = mysql_query("SELECT * FROM menus_show WHERE id = $meal1 ;"); while($row = mysql_fetch_array($result)) { $image = $row['imagesmall']; $title = $row['title']; $description = $row['text']; } } if (isset($meal2)){ $result = mysql_query("SELECT * FROM menus_show WHERE id = $meal2 ;"); while($row = mysql_fetch_array($result)) { $image = $row['imagesmall']; $title = $row['title']; $description = $row['text']; } } session_unregister('$order'); $orderw2 = unserialize($_SESSION['orderw2']); $array = $order->getData(); $meal1 = $array[0]; $meal2 = $array[1]; $meal3 = $array[2]; $meal4 = $array[3]; $meal5 = $array[4]; $meal6 = $array[5]; $meal7 = $array[6]; include('config.php'); $link=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD)or die("Could not connect: " . mysql_error()); mysql_select_db("_simp"); if (isset($meal1)){ $result = mysql_query("SELECT * FROM menus_show WHERE id = $meal1 ;"); while($row = mysql_fetch_array($result)) { $image = $row['imagesmall']; $title = $row['title']; $description = $row['text']; } } <? if (isset($meal2)){ $result = mysql_query("SELECT * FROM menus_show WHERE id = $meal2 ;"); while($row = mysql_fetch_array($result)) { $image = $row['imagesmall']; $title = $row['title']; $description = $row['text']; } }
  21. rn14

    Array

    I didnt think you were corbin. Could you help me to get the right approach with the code that i have?
  22. rn14

    Array

    Thanks, How do i prevent this error from happening when no data is present?? Fatal error: Call to a member function getData() on a non-object
  23. rn14

    Array

    Thanks, can i let the value returned equal to a variable??
  24. rn14

    Array

    could anybody help me with this???
  25. rn14

    Array

    im trying to learn oop at the moment could you explain the reasons for its poor design and how I can rectify them? When i use this $array = $order->getData(); to access getData how will I extract the the different values in the array? Thanks and apologies for the basic and stupid questions
×
×
  • 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.