Jump to content

GuitarGod

Members
  • Posts

    93
  • Joined

  • Last visited

Everything posted by GuitarGod

  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
  15. That's exactly what I was trying to do, your code has worked fine Thank you very much!
  16. Quite right, my apologies. I should have checked that the information on the site was updated and relevant. As you pointed out, it isn't.
  17. Glad to help When I first started to learn PHP, this site really helped (http://www.xentrik.net/php) as it went through all the basic. Good luck!
  18. If I understand correctly, "flyer.php" if your printable page. Open this page and go to line 151 and DELETE it: "$frontend_labels[PRICE]" => "$default_currency$thou_sep", This will remove the price for appearing if your specifications table. Now to add it to the title. Go to line 84, you'll find: <h1>$row_array[1]</h1> REPLACE it with: <h1>$row_array[1] $default_currency$thou_sep</h1> Lastly, CUT line 137 $thou_sep = number_format($row_array[14]); and PASTE it on line 81 (just above print ") As you move code about, the line numbers above may change very slightly, so I've included the relevant code to look for.
  19. Hi Guys, I'm having a little trouble trying to use an IF statement in the WHERE clause of a mysql. What I'm trying to achieve, is that if m.message_type is set to 1, then I would like the m.message_id to match mt.message_id, otherwise I want mt.message_id to equal -1. I'm sorry if I've overcomplicated it, I'm just not sure how it's written in SQL. SELECT m.message_id, m.message_type, mt.message_id, mt.message_text FROM messages m, message_text mt WHERE ( if m.message_type // // etc ) Any help is, as always, fully appreciated
  20. Hi guys, In Ajax, I'm having trouble firing several Ajax calls at the same time. It seems luck of the draw which ones fire and which ones don't. Firing them one at a time or in a sequential order - they work fine, but trying to fire them all together makes some not work. Can anyone help? Code examples function ajax( action ) { var ajaxRequest; try { // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch ( e ) { // Internet Explorer Browsers try { ajaxRequest = new ActiveXObject( 'Msxml2.XMLHTTP' ); } catch ( e ) { try { ajaxRequest = new ActiveXObject( 'Microsoft.XMLHTTP' ); } catch ( e ) { return FALSE; } } } // Ajax response! ajaxRequest.onreadystatechange = function() { if( ajaxRequest.readyState == 4 ) { if ( action == 'connection' ) { // document.getElementById( 'element' ).innerHTML - ajaxRequest.responseText; } else if ( action == 'connection_methods_box' ) { // document.getElementById( 'element' ).innerHTML - ajaxRequest.responseText; } else if ( action == 'connection_status' ) { // document.getElementById( 'element' ).innerHTML - ajaxRequest.responseText; } } } // Send data to ajax.php if ( action == 'connection' ) { // Some paramaters here } else if ( action == 'connection_methods_box' ) { // More paramaters } else if ( action == 'connection_status' ) { // Even more } // Send! var data = 'action='+action; ajaxRequest.open( 'POST', 'ajax.php', true ); ajaxRequest.setRequestHeader( 'Content-type', 'application/x-www-form-urlencoded' ); ajaxRequest.send( data ); } In ajax.php, code is similar to: <?php if ( $_POST['action'] == 'connection' ) { // stuff to do } etc.. etc.. ?> I know I could fire one Ajax query, then simply call the other once the first has finished, then the next one once the second has finished (and so on), but if possible I'd really like to fire them all at once. Any help is appreciated.
  21. Hi all, I'm having some trouble with Javascript onkeyup, not quite sure why it's not working. <script type="text/javascript"> document.getElementById( 'text_input' ).onkeyup = function() { // do stuff } </script> <input type="text" id="text_input"> I know it can be done by adding onkeyup="myfunction()" to the input textbox, but for development purposes it would be easier done using the style above. Any ideas?
  22. Upon more research I've found that changing "localhost" to "127.0.0.1" in the MySQL connection string solves the problem entirely. I'm not sure why this is, but it's good enough for me.
  23. Hi all, I'm not to clued up on Apache/servers, so if this is a basic problem I do apologise. I've been working on a script for a while using a local development server (WAMP) and have recently switched to another local server, my script however has started to run very slow - sometimes it times out, and all images don't load (not a problem with my old server). phpMyAdmin (also hosted on my server) runs fine, but if my program is open in another tab at the same time, it slows phpMyAdmin right down. Any ideas what it could be, and how to fix it? Or even check for errors? My script is too large to post here, but it never gave me a problem on my old server. Any light you could shed is appreciated Thanks
  24. I hadn't thought this far ahead, and this will probably become a problem at some point! Thank you very much for the code and for the advice It is 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.