Jump to content

GuitarGod

Members
  • Posts

    93
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

GuitarGod's Achievements

Member

Member (2/5)

0

Reputation

  1. Thank you both sincerely! I've taken your advice Benanamen and changed the tables accordingly. And Barand, as ever, your code is spot on I've been trying to add a GROUP_CONCAT to the query so that if a student belongs to any schools, the school ID and name are returned. I'm not having much luck but I'll keep trying. Out of interest, is there an easy way to achieve this? Thanks once again for all your advice/help!
  2. Hi all, I'm after some advice about these tables and whether I'm using them in the most efficient way. Currently I have 4 tables; Students, Schools, Administrators and School members. The Students table is simply a list of students with an 'admin_id' field - which relates to an administrator in the Administrators table who created the student (the student may not yet be a member of any School as explained further in the Schools and School members tables). STUDENTS +---------------+---------------+---------------+ | Student ID | Admin ID | Student name | +---------------+---------------+---------------+ | 1 | 1 | Mike | | 2 | 1 | Edward | | 3 | 1 | John | | 4 | 1 | George | +---------------|---------------+---------------+ The Administrators table contains the people who will use the script and oversee the Students/Schools table ADMINISTRATORS +---------------+---------------+ | Admin ID | Admin name | +---------------+---------------+ | 1 | Mr James | | 2 | Mr Davies | | 3 | Ms Lewis | | 4 | Mrs Walsh | +---------------|---------------+ Just from the example above, you can see that all current students have been registered by Mr James. The Schools table, similar to the Students table, is simply a list of Schools registered by an administrator (containing an 'admin_id' related field). SCHOOLS +---------------+---------------+---------------+ | School ID | Admin ID | School name | +---------------+---------------+---------------+ | 1 | 1 | Hilbre | | 2 | 1 | Ridgeway | | 3 | 2 | Grammar | | 4 | 2 | Calday | +---------------|---------------+---------------+ From the above example, Administrator Mr James has registered Schools Hibre and Ridgeway, whilst Mr Davies has registered schools Grammar and Calday. Now, for the complicated part that I'm struggling with. Administrators and Students should be interchangeable. For example, Administrator Mr James may 'belong' to any School created by Mr Davies - as may any of his students. I've tried to keep track of Administrators/Students/Schools by using a School members table. SCHOOL MEMBERS +---------------+---------------+---------------+ | *Member type | Member ID | School ID | +---------------+---------------+---------------+ | 1 | 1 | 1 | | 1 | 2 | 2 | | 1 | 1 | 2 | | 0 | 2 | 2 | +---------------|---------------+---------------+ * 0 = Student 1 = Administrator Without trying to complicate matters, the table above shows that Mr James and one of his students are both members of a School registered by a different administrator. The query I'm trying to write would be; If I'm logged in as Mr James (or any other administrator), I'd like to query these tables to get a list of students that I've created, students that belong to my schools AND students that belongs to other schools that I'm a member of. I hope that makes sense and I hope I haven't over complicated it - is there's any easier way to handle this data, I'm all ears! EDIT: In the above query, I'd also need a GROUP_CONCAT list of Schools that the student belongs to (if they belong to any) if possible! Thanks for any help
  3. Hi all, I'm currently using jQuery to upload multiple images, however, sometimes we're uploading 50+ images and each image is copied/resized to a thumbnail on upload, so we're breaching out max execution time among other things. Is it possible to alter jQuery to send each image individually thus keeping within our execution time and allowing us to track progress on each individual upload. So far we have: $( document ).on( 'submit', 'form[name="upload"]', function() { var data = new FormData( this ); $.ajax({ type : 'POST', url : 'upload.php', async : false, cache : false, contentType : false, processData : false, data : data, success : function( response ) { alert( response ); } }); return false; }); HTML is pretty much: <form name="upload" enctype="multipart/form-data"> <input type="file" id="file_upload" name="file_upload[]" multiple><br> <input type="submit" value="Upload"></form> Any help would be appreciated. Cheers!
  4. Seems like too many singular quotes, should be: echo $currentBefore . __( 'Ads tagged with', APP_TD ) . ' ' . single_tag_title('', false) . ' ' . $currentAfter;
  5. Your structure seems to follow a pattern of '?dir=DIR1/DIR2/DIR3 etc, and you want to display a title of DIR1 - DIR2 - DIR3, the following code should suffice. if ( isset( $_GET['dir'] ) ) { $explode = explode( '/', $_GET['dir'] ); $dir_count = count( $explode ); $title = ''; $i = 1; foreach ( $explode as $k ) { $suffix = ( $i == $dir_count ) ? '' : ' - '; // Seperate the directory names with - $title .= $k . $suffix; $i++; } } If you place this code before your title code (e.g. <title>COUR...</title>) Then change your title code to <title><?= $title; ?></title>, it should work.
  6. Hi Folks, My apologies if this isn't posted in the wrong forum - I'm assuming this is a CSS issue but may turn out to be a HTML problem. I'm currently developing a website for a photographer, which can be found here: http://www.byrnecomputingservices.ie/CP/ At the bottom of the page on the left-hand-side is the photographers and on the right-hand-side is his email address. The problem I'm having is that when the site is viewed in full screen on a large monitor, both of these contact details sit underneath the page content and not at the bottom of the screen - is there an easy way to fix thing? Problem can be seen here Thanks in advance for any and all help, Regards, Mike
  7. Hi Barand, Thank you for your response. I tried working on one of your previous answers but for some reason it wouldn't work. Perhaps you can see what I'm doing wrong: SELECT m.user_id, m.message, CASE user_type WHEN 0 THEN u.username WHEN 1 THEN a.admin_username END AS username FROM messages m LEFT JOIN users u ON m.user_id = u.user_id LEFT JOIN administrators a ON m.user_id = a.admin_id The users table consists of exactly those two fields above (user_id, username), where as the admin table consists of many more fields than written above, so I figured having a separate table would use less space than using the admin table to store two pieces of data.
  8. Hi all, I have two different user tables - one for regular users (user_id, username), and one for administrators (admin_id, admin_username). I also have a table called messages (message, user_type, user_id). I'd like to query messages so that if user_type is equal to 0, then the user_id field in messages table will match up to a user_id row in the users table. However, if user_type in the messages table is equal to 1, then the user_id field in that table should match up to admin_id in the administrators table. I hope that isn't too confusing. I've tried CASE and JOIN but just can't seem to get it to work. Sincere thanks to anyone who can help, Regards
  9. If memory serves, this isn't the first timed you've helped me and got the answer spot on. Many thanks, sincerely
  10. Hi Barand, Yes both the customers and non_customers table have a customer ID. Regards.
  11. Hi all, I'm not terribly good when it comes to SQLs, so forgive me if this seems like a dumb question. I have 3 tables (orders, non_customers and customers). Both the non_customers and customers table have a field in them called 'details'. In the orders table, I have a field called 'customer_type'. What I'm trying to convey is that if the 'customer_type' value is 0, then I would like the 'details' field pulled from the non_customers table, where as if the 'customer_type' value is 1, I'd like the 'details' field pulled from the customers table. SELECT o.*, n.*, c.* FROM orders o LEFT JOIN non_customers n ON o.customer_type = 0 LEFT JOIN customer c ON o.customer_type = 1 The code above doesn't seem to 'collate' the tables, it seems to return all of the orders, then all of the customer details. Any help is appreciated Regards.
  12. Hi all, I'm using jQuerys ajax function to send some data, however I would like to add a function to it that would gather up more data to be sent. Here's what I'm trying to do: $.ajax({ type : 'POST', url : 'ajax.php', data : { action : 'customer_details', more_customer_details( 'complaint' ) }, success : function( msg ) { // } }); function more_customer_details( section ) { var cus = { details_sent : '1' }; if ( section == 'complaint' ) { cus['name'] = $( '#'+section+'_name' ).val(); cus['msg'] = $( '#'+section+'_msg' ).val(); } else if ( section == 'support' ) { cus['id'] = $( '#'+section+'_id' ).val(); } return cus; } As you can see, the reason I'm wanting to use a function to gather extra details is because the object parameters and values will be changed based upon a selected action, however this doesn't seem to work. Is there any way to return an object and it to jQuery ajax data section? Thanks for any and all help
  13. Hi all, I'm currently using jQuery's load function to send/load data into a page element, but I'm having trouble figuring out how to send dynamic data. var option_count = $( '#opt_count' ).val(); // This number is subject to change on every page var opts = ''; for ( i = 0; i < option_count; i++ ) { opts = opts+'&option_'+i+'='+$( '#option_'+i ).val(); } // So the data above could be &option_0=7&option_1=4&option_2=9 etc // but I can't seem to send option as an individual parameter // I've tried $( '#contain' ).load( 'receiver.php', { page_no : "2"+opts, }); // I've also tried $( '#contain' ).load( 'receiver.php', { page_no : "2", opts }); // What I'm trying to convey is $( '#contain' ).load( 'receiver.php', { page_no : "2", option_0 : 7, option_1 : 4 // etc etc.. }); However, the number of options and their values are dynamic and subject to change. Any ideas?
  14. Hi all, I have an array called 'menu', which when put through print_r, currently outputs: Array ( [4_00] => Array ( [0] => 1 ), [3_00] => Array ( [0] => 1 ), [7_00] => Array ( [0] => 1 ) ) I want to create an expression that will search this array for any keys beginning with '4_'. I have tried with this: $matches = preg_grep( '/^4_/', $menu ); But that doesn't seem to work. Any help? Much appreciated
×
×
  • 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.