Jump to content
Larry Ullman's Book Forums


  • Posts

  • Joined

  • Last visited

Everything posted by sam67

  1. That's great, it make so much sense! If I want to also cater for teachers setting assignments to 5-10 students not just a class, how would I include this with the same thinking? thanks again, I really appreciate your time.
  2. Hi Larry, I have one last challenging database design question for you. I am looking at a teacher setting a task for students to complete, what is a better way to store the homework and student relationship. The requirements: The teacher can set homework to a group The teacher can specify exactly which students it is set to Originally I looked at a table that stores a record for the student_id and the homework assigned too them (student_id, homework_id). but if a teacher selects 2 classes (of 30 students in each) to set homework too, I will have to insert 60 new records! insert into homework_set_too(student_id, homework_id) VALUES (111, 01),(222, 01),(333, 01), etc. My idea to combat this is adding a new column for set_to_group (student_id, set_to_group, homework_id). If student_id is null the homework is set for the whole group but if student_id has a value the homework is set for one specific student. Sorry if I didn't explain this well. In a nutshell when a teacher sets homework for a group I don't want to insert 60 records as this is probably going to be a really expensive query to run with more then one teacher! Am I thinking correctly? thanks again
  3. Wow, I had not thought of creating it that way but it actually makes so much sense. It looks so simple but saves so much time later down the road! Thank you so much for this, I really like Database design but can easily over complicate projects. Always love learning from you, Stay safe, Sam
  4. Hi Larry, Yes each type of user (student, parent,teacher) has to login to view their profiles. A teacher can also be a parent but I think this might be a case of different accounts to not complicate things. My thought would always be have 1 table of all users and then have one column specify the relationship in that table, But I have been looking at performance when it comes to over 1000+ users and wanted a more experienced answer that could scale beyond that. thanks again, Sam
  5. Hi All, Im building a Web App with 3 different types of users: Students Parents Teachers Should I store them all in one database table or separate tables? I am looking for the scalable best practice option with 4000+ minimum users. All in one table option, I would have a column with 1, 2 or 3 to specify the users type. Any help would be great, I can do both but looking for best practice really. Thanks in advance!
  6. Hi HartleySan, Thank you so much for the help, that makes perfect sense and I will try to write a test script that uses MVC, OOP and Ajax altogether with the approach you have given me! thanks for clearing my mind up, Sam.
  7. Hi HartleySan, So if I take an example from the book, Chapter 9 (page 301), "The User Class". Lets say the data is being fetched by an ajax call rather then on page loads. You write your javascript part and post any data needed to the php ajax script. then in your php ajax script would write your database query to fetch the user. but would you try and add the result to a class defined as UserClass or send the result back via Json? I am just a little unsure as to the cross between the two and maybe need to find an example to clear it up in my mind. Many thanks for the time and help, Sam
  8. Hi Larry, I have now read four of your books and have started the transition from procedural php to object oriented php. I use a lot of Javascript and Jquery Ajax requests now due to the enhanced benefits it can give you but am unsure of the best practice's of using ajax request with object orientated php programming, specifically structure! I wondered if you can maybe give me an example or point me in the right direction where i can learn this? p.s. I also wanted to say a massive thanks as I now work daily for a company programming!. This all started from the first book I read of yours "PHP and MySQL for Dynamic Websites Fourth Edition", I could not have got this far without you and your amazing books which I keep as treasures on my shelf and will do for the rest of my life! thanks for everything. Look forward to your response, Many thanks, Sam
  9. hi yeah thanks i think i have figured it out. i have one more question, I copyed a tutorial on youtube the link to it is below: It's ajax page loading, so you dont have to reload a different page. i got it to work. But on one page i have json data which does not load when you click on the page anymore. it works when you refresh the page but that defeats the purpose of ajax page loading, my question is: How can i load a page that has json data on it with out refreshing the page ??? many thanks for all the help i really appreciate it, sam.
  10. hi yeah sure, so im trying to copy what you have in the book on chapter 15 pages 578, 579, 580, view.php. So when someone clicks the button it submits a bid or a value to the database. i am trying to display a similar concept however struggling with the bidding inputs being on the item list, instead of having to click on the item to then follow onto bid. so therefore not having to click on every item, the bidding inputs will be displayed on each item on the list. Problem i have is individualing ID'S between each item, because they are all on the same page all the item ID'S are over writing one another to the last record. I need them to stay individual to their own items so when theyre passed onto the javascript it can submit the item as clicked on by the user. Thanks for your help, hope to hear from you soon. Sam
  11. Hi I'm trying to find out 2 things, 1) how to pass a button value that comes from mysqli while loop to javascript then on to Ajax script. 2) how to pass a php array on to javascript and then onto the Ajax script. I will be really grateful if anyone could help. many thanks sam
  12. Hi Larry my name is sam can i first start by saying i absolutely love your books. i am currently working on a project where i have built the php side of things and now working on enhancing using javascript. i am adapting your script from your Modern javascript develop and design book on chapter 15, (view.js). But the problem i have is my php script loops through the database to show results and i am trying to pass the id of the data, like you do in your view.php script to the view.js script with, <script> var itemId = ' . $itemid .'; </script> BUT i have a while loop on the php script and the script tags are in the while loop like this, $query = "SELECT `item_id` FROM items"; $results = mysqli_query ($dbc, $query); while (list ($item_id ) = mysqli_fetch_array($results, MYSQLI_NUM)) { // Start the while Loop here ... echo '<form action="" method="post" id="bidForm" class="bidForm"> <input class="button" type="submit" value="Like" title="Like"> <input type="hidden" name="item_id" id="item_id" class="video" value="' . $item_id . '"> </form>'; ?> <script> var itemId = "<?php echo $item_id; ?>"; </script> } // End of while Loop here .. then link to external js script <script src="js/ajaxBid.js"></script> Just so you know this is not exact just example above but it does the exact same thing. So the problem is where it Loops the var itemId gets more then one value so you don't get the value of the button clicked sent to the ajax script. How can i get the id of the button clicked in my js script while still in the while loop???? sorry if this is really confusing i will answer any questions you might have. if you or anyone could explain in the simplest possible way where I'm going wrong as not brilliant at javascript yet, that would be amazing been stuck for ages on this. many thanks, Sam
  • Create New...