Jump to content

George Botley

Members
  • Posts

    112
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.torindul-designs.co.uk

Profile Information

  • Gender
    Not Telling
  • Location
    United Kingdom

George Botley's Achievements

Member

Member (2/5)

0

Reputation

  1. Here's the array structure: Array ( [0] => Array ( [0] => name=Ecommerce Management [1] => nextduedate=2012-05-11 [2] => status=Active ) [1] => Array ( [0] => name=Page Management [1] => nextduedate=2012-05-11 [2] => status=Active ) ) 11 I would like it to be like this: $addon["0"]["name"] = Ecommerce Management $addon["0"]["nextduedate"] = 2012-05-11 $addon["0"]["status"] = Active You get the idea... Here's my code so far... //Check License Addons function license_addons($addons) { //Addons are passed in a callback seperated by a vertical seperator - | - so lets explode the addons value $addons = explode("|", $addons); //Let's pass through each child array and explode its values. The new delimited value is ";". foreach($addons as $key=>$value) { //Explode the child arrays at the delimited value ";" $addons[$key] = explode(";", $value); } } Any ideas??
  2. Hi, Here's the array under the $img variable Array ( [0] => Array ( [url] => IMG_0002.JPG ) ) 1 It would normally have multiple values, depending on the amount the users adds to the form. Basically, for key '0' on the array I wish to then get the value of the sub array "url". How would I do this in a foreach loop? George.
  3. Thanks for all of your comments guys, Each method is good in solving my problem although PFMaBiSmAD's suited my plan best. The events repeat on the same day of every week, so a timestamp would not work for simply saying Monday.. or would it? George.
  4. Just marked this as complete, but it isn't after confirming.... Any ideas?
  5. Hello, I have classes in a database with no set UNIX date, just the day like Wednesday and in two other columns the start and end dates. I want to be able to order by the day first and then by end_time but php orders the day column by spelling and not the day it holds in chronological order. Is there anyway to change the query to order the day column as a date? See the query below? $query = "SELECT * FROM zumba_timetable WHERE end_time>'$current_time' ORDER BY day, end_time ASC LIMIT 0,1";
  6. I just made some amendments and it's sorted. Thanks for you help anyway.
  7. Here is my query: $query = "SELECT * FROM zumba_timetable WHERE day='$today_day' AND end_time!<'$current_time' ORDER BY end_time ASC LIMIT 0,1"; Essentially, I am checking an event timetable to find the next event today, where the end time is not before the current time. The variables are already set in the code, but the script returns this: I have swapped the ! and < around and even added an = but to no avail. Any clues?
  8. Hello, I am struggling here. Basically I have integrated a Google Maps API with a website to show the location of the next session. This script will take the next session and return its location, so the lat and long can be fetched from another table and fed into the API. Here is the timetable in a MySQL table: I am trying to do/say the following: * Show current session (if in progress) * Show next session. (Only to be fetched from db when the previous session has expired) * If there are no sessions left on today's date, show next session on next day with sessions. How could I write this as a PHP query in order to the fetch the location data? Thanks, George.
  9. Ah I see, thank you for all your support mjdamato.. I now have a cleaner; working solution, and have learnt to use the ternary operator in future... Less lines of code = less strain on server, which is a plus.. George.
  10. Thank you, I was wondering why it updated every records location... Would you be able to explain what the ? does in a query? I would like to make use of it if it helps, but knowing its purpose would help me to implement it going forward. Thanks, George.
  11. If you intend to use the GET function primarily for database queries, be careful what take from it. Don't be prone to what is known as injection, whereby a database can be fooled into thinking it is being provided with correct information, when it clearly isn't. We would need to see the rest of your script associated with $row[] to see how you are making use of it. George.
  12. Thank you for your support, Would you say this is now a more satisfactory, and clean way to code what is needed? The reason my code was messy was probably down to not knowing an ability to reference an ID in an array name on a form. <?php /* This script is for use on the Manage Menu's pages and updates all menu items. */ /*==================================*/ /* DATE BASE CONFIGURATION */ /*==================================*/ include_once "../../config/config.php"; /*==================================*/ /* SET VARIABLES */ /*==================================*/ $id = $_POST["id"]; $active = $_POST["active"]; $menu_name = $_POST["name"]; $menu_file = $_FILES['menu_file']; $i = "0"; /*==================================*/ /* SECURITY MEASURES */ /*==================================*/ array_map('mysql_real_escape_string', $menu_name); /*==================================*/ /* Update Menu Names */ /*==================================*/ foreach($menu_name as $id => $name) { //Variables for file upload $file_name = $menu_file["name"]["$id"]; //name of file on users machine $file_type = $menu_file["type"]["$id"]; //type of file being uploaded $file_size = $menu_file["size"]["$id"]; //size of the uploaded file in bytes $file_error = $menu_file["error"]["$id"]; //returned PHP error codes for upload $file_temp = $menu_file["tmp_name"]["$id"]; //temporary name on server //If empty menu name, forward to error. if(empty($name)) { header("Location: ../../../index.php?page=Menu's"); $continue="0"; } //Is a file upload needed? if(isset($file_name) && $continue!="0") { //Include handler.php, for file validation and upload include_once "./hanlder.php"; //Update database $query = "UPDATE menus SET menu='$name', location='$file_location' WHERE id='$id'"; $query = mysql_query($query) or die(mysql_error()); } //If a file upload is not required, update database excluding file location. elseif(!isset($file_name) && $continue!="0") { $query = "UPDATE menus SET menu='$name' WHERE id='$id'"; $query = mysql_query($query) or die(mysql_error()); } } /*==================================*/ /* Update Active Status */ /*==================================*/ //Update active status if all validation and earlier tasks have completed. if($continue!="0") { //Convert to comma separated string $ids = implode(',', $active); //Create and run one query to update checked records $query = "UPDATE menus SET active = 1 WHERE id IN ($ids)"; mysql_query($query) or die(mysql_error()); //Create and run one query to update unchecked records $query = "UPDATE menus SET active = 0 WHERE id NOT IN ($ids)"; mysql_query($query) or die(mysql_error()); } /*==================================*/ /* END OF SCRIPT */ /*==================================*/ header("Location: ../../../index.php?page=Menus&errors=Menu_Change_Success"); ?>
  13. Thank you for your suggestions, I apologise if I came across as ungrateful.. I will probably take on your suggestion to allow the user to update individual rows on a separate page. When thinking about it, it does make more sense, for the sake of the checkboxes, I might replace them with a drop down so a value is received either way. George.
  14. Well, do I say thanks? In some ways yes, thank you for your comment.. but I'm sure you once were scrappy with your code at some point. We all learn new things every day. I came on here to ask for assistance in how to improve the loop, as, from a previous topic on here a while back, I had been advised to use foreach loops when there was more than one line of data to modify in a database from the same form fields in the same form. If I was to re-write the script from the beginning then, what would you suggest (not asking for a complete script from yourself), but just wish to understand where I should begin... Why is it not good practice to loop it? as it's not only the checkboxes I want to deal with, it's other fields too?
  15. Hmm, The only reason it would be entirely necessary would be if you were running clusters of servers, like Facebook or eBay, pretty much any larger database driven website where copies are needed for load balancing... One copy is sufficient for most tasks. Just backup your db and store it in another location.
×
×
  • 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.