Tagged: homework Toggle Comment Threads | Keyboard Shortcuts

  • Joel L 08:43 on May 8, 2011 Permalink |
    Tags: homework   

    RateMyFood, for Wednesday 

    By Wednesday 08:00 AM you will deliver to me your RateMyFood application.

    The UI must be feature-complete — i.e. no “Oh, I haven’t got around to adding x yet” things.

    Has all forms for data entry.
    Has links that take me from one page to another.
    Homepage is index.php

    Submit requests for help and clarifications before the deadline, not after.

    No USB sticks.

    • Paavo Viilup 19:13 on May 8, 2011 Permalink | Log in to Reply

      Make it so.

    • alex 18:04 on May 10, 2011 Permalink | Log in to Reply

      I have a two questions at the moment. My first question would be that in my index file I have the logged in function whether it is true or false. When it is true all of the pages can be accessed but when it is false then only the login and register pages are accessible. Now the problem is that when it is false and I want to display only the login and register pages then I want to do this without the navigation. At the moment when i turn it to false then the navigation is also there and is disturbing. I also shared the whole thing with you in dropbox if you want to have a look at it. The second problem is that on the so to say userpage when I want to go to the second page then it goes to the home page. I can’t seem to pinpoint the error. Maybe you can find it and tell me.

      • Joel L 18:14 on May 10, 2011 Permalink | Log in to Reply

        If you don’t want to show the navigation for non-logged-in users, just use:

        <?php if ($logged_in) { ?>
        # navigation menu
        <?php } ?>

        Remember, if statements have to be used whenever you want to show/change something based on some condition.

        “The second problem is that on the so to say userpage when I want to go to the second page then it goes to the home page.”

        What “user page”, what “second page”?

        Please use the names that you use on your php page, so I’ll understand a bit more! 🙂

        • alex 18:23 on May 10, 2011 Permalink | Log in to Reply

          I am not sure I understand the first solution in using a id for the navigation menu 😀 I know I am dumb 😀

          But the second problem is that on the webpage when you go to the friends frides page then by clicking on a friend it opens up the userpage or the friends fridge and on that page there is a button next to go to the second page. The first page is userpage.php and the second one is userpage2. I have referenced in userpage to go to userpage2 by clicking next but for some reason it takes me to home.php.

          • Joel L 18:30 on May 10, 2011 Permalink | Log in to Reply

            re: using #id – wordpress ate the php tags and I didn’t notice at first. Fixed now.

            re: userpage2 – you must add it to the $allowed_pages array.

            • alex 18:38 on May 10, 2011 Permalink

              K got it working thanks a lot, but is it okay or what is it lacking just to know what to add there or improve?

              Another question too. Is it possible to implement the code in a way that when somebody clicks on the login button and then gets logged in so that a person does not have to change the logged_in statement? Or is a database needed in order to do that?

              One more. As you have noticed that every item that you click brings you to a rating page. The only thing is that I have not figured out how to make it so that if you click on a food item then it takes you to that specific food item and lets it rate that. Basically only the picture and info have to change. Any ideas?

            • Joel L 18:59 on May 10, 2011 Permalink

              Well, does the page have all the functionality you want? For example, where’s the search results page?
              Is the food category menu always visible? Even on the login page? Why? Why not?
              Why are links in the My Friends table not identifiable as links? Why are the emails not clickable?

              If I click a category, what do I see? Are these food items in my fridge only? Or all fridges in the system? How do I know which?

              Just keep polishing existing functionality, don’t worry about login code yet.

            • Joel L 19:09 on May 10, 2011 Permalink

              Re: different food items – we’ll come to that later.

    • Sander 19:11 on May 10, 2011 Permalink | Log in to Reply

      Not wanting to keep my user pages as facebook pages, i started creating separate user pages. To access these pages, I need to perform arrayception. Namely, on the user page (not the wrapper anymore) i need to have another array of pages and some more PHP code. So how do i shot w- i mean, how do i get the pages to show up? Right now, I have Silver’s page in a separate users folder (the PHP actually works, go figure), but when i try to see his profile page, the home page is shown instead.

      • Joel L 19:20 on May 10, 2011 Permalink | Log in to Reply

        And where might I be able to see your code?

        • Sander 19:21 on May 10, 2011 Permalink | Log in to Reply

          It’s on my USB stick! (putting it on dropbox atm)

        • Sander 19:36 on May 10, 2011 Permalink | Log in to Reply

          Btw, the problem is most probably on the “friendz.php” page

          • Joel L 19:47 on May 10, 2011 Permalink | Log in to Reply

            If you go to ?page=friendz&user=Usersilver, then
            1. The friendz.php page is included
            2. The friends page includes the silver page.


            If the index.php page includes the friends page, and both start with , then the resulting page has a structure like:


            and this is… err, wrong.

            Please review the original sample I made.

            The pages that you include into index.php must only have the fragments that change, not the entire html page structure.

            • Sander 19:53 on May 10, 2011 Permalink

              Hmmm…so how bad is it if i leave in the facebook integration (for users) ?

            • Joel L 20:03 on May 10, 2011 Permalink

              integration == links?

            • Sander 20:07 on May 10, 2011 Permalink

              Pretty much, yeah. Or could i just copypasta a nifty facebook plugin of some sort?

            • Joel L 20:10 on May 10, 2011 Permalink

              First, make everything else work perfectly!

            • Sander 20:14 on May 10, 2011 Permalink

              What’s missing?
              Anyway, I’ve removed all of the unnecessary tags, but I’m still rather hazy on how to make the actual user specific page show up….

            • Joel L 20:19 on May 10, 2011 Permalink

              fixed it for you.

              $allowed_users vs $allowed_pages.

              i.e. if you copy-paste stuff, make sure to also change things…

    • Silver 15:26 on May 11, 2011 Permalink | Log in to Reply

      better late then never, right?

  • Brent 09:35 on May 5, 2011 Permalink |
    Tags: homework   



  • Joel L 08:35 on May 1, 2011 Permalink |
    Tags: homework   

    The partially php-ized site is here: http://fkingtiny.com/4x

    To reiterate – homework for next time is:

    make your site dynamic (has common “wrapper” (index.php), can switch between pages; has functional logged in/logged out states)
    also, improve the UI further

    and ask questions here, or in person, or via email, or via facebook, or whereever.

    Aim is to get your application into a state where it’s perfectly usable, only without actually showing or saving real data (that will come later).

    • Brent 20:31 on May 2, 2011 Permalink | Log in to Reply

      ma võtsin su koodijupikese, ja vaatasin saiti. Kui ma vahetan $logged_in = “false” —> “true” peale siis mulle tuli error, et sul on 52. rida vigane, seoses include($path), küsimus oleks siis, et miks?

    • Joel L 20:36 on May 2, 2011 Permalink | Log in to Reply

      Rida 43-44 ütlevad, et kui on $logged_in, siis luba lehed “‘home’, ‘my_ratings’, ‘my_settings’, ‘member_settings'”

      aga reaalselt pole ühtegi lehte peale home.php olemas, ja siis kui mingit mitte-home lehte üritad vaadata, ei leia ta soovitud (olematut) faili üles

      kui $logged_in = false, siis seda ei juhtu, kuna lubatud on ainult ‘home’, ja kood ei ürita kunagi ühtegi teist lehte include()-da

  • Brent 09:34 on April 28, 2011 Permalink |
    Tags: homework   


  • Joel L 15:27 on April 25, 2011 Permalink |
    Tags: homework   

    How is your progess with the food app user interface (html+css)?
    Any specific problems/questions?

  • Brent 19:57 on April 7, 2011 Permalink |
    Tags: homework   


    The point of the website is to show different foods, lets say from the fridge, and let people rate them.

    The system will use two IDs

    • Food_ID
    • User_ID(divided into Admin and Average user)

    There would be 2 databases.

    Food database:

    • Food_ID
    • Name
    • Bio(well, if you want to tell a story about where you got the egg, like from a farm or shop. or special features)
    • Ratings
    • Expiring date

    User database:

    • User_ID
    • User_Type(Admin, Average user)
    • Name
    • Bio/Info(Bio and other user related info, like day of creation)
    • Rating history

    Also tables:

    • Main raiting page
    • Personal rating page
    • Expiring table

    Now that the parts have been laid down, how does it all come together:

    As said before, the system will mainly use two ID-s. First of all Food_ID. This is used to recognize the food that is being rated. A table, which users can see, will send the request to the database and retrieve the information for the required food_ID. The Ratings used in that database, will use the information(ratings) given by the users and record em in the database. After a certain amount of time, the ratings will be updated by simply calculating the mean( the sum of ratings given / the sum of ratings = Answer).
    The expiring date will be used as a trigger. If the item has past the expiring date for a day, it would be removed from the table.
    Now this is where the Food_ID makes its biggest play. On to the User_ID

    The User_ID also retrieves information from the database. Now, depending on the User_type, Admins and other users will see a slightly different tables. The average user will see the name of the food, expiring date, rating(of the food) and a field, where they can put their own rating. The ratings themselves, as said before, are related to the Food_ID. Now all users have their own rating page, where they can see and change their past ratings. It works like this: When a user has rated an item the Food_ID of that item will go into the user’s Rating history. Every time a user views the main table the Food_IDs in his rating history will not be displayed. On the personal rating page, there will be a table which shows only those foods which the user has already rated for(like the name implies).
    With the Admin, it’s a little bit different. First of all the Main rating page has a extra field, where the Admin can add items. This will be a row, which has empty spaces in the places of data.
    In the Personal rating page, there will be the same rating table, like the average user has.

    The Admin will also have an Expired food table where the foods, which have passed the “one day over expiring date” line, will be displayed. From that table, the Admin can delete the items from that table and thus from the entire database. This helps the admin to keep on eye on the things they have, for example: Mom can see which foods have expired in the fridge.

    So this is kind of it, I hope it makes sense 😉

    • Erik-Silver Toomere 12:23 on April 10, 2011 Permalink | Log in to Reply

      Two things.
      Will the user_type be easily manipulated? That is, will the giving admin rights to somebody be easy (a “make admin” button) or a real pain (modifying databases/creating new users and copying old user info)?
      Also, again the expired food thing, just making the background go red or adding a note that “CAUTION! Food x hours/days over exp. date” would be smarter so that users can decide wether they will consume the food or throw it out (since expiration dates never are accurate).
      Otherwise, GJ!

      • Brent 14:38 on April 10, 2011 Permalink | Log in to Reply

        The user_type could be manipulated like that(easily). The user_type will simply enable the user to see the awesomer tables and manipulate them, otherwise the user function is the same, they can rate and stuff still, so only accessing the pages, the function(which works with type) can choose to either show or no, depending on the type.

    • Joel L 07:33 on April 11, 2011 Permalink | Log in to Reply

      (I’ll finally read this and give feedback later today, sorry for the long wait)

    • Joel L 22:34 on April 11, 2011 Permalink | Log in to Reply

      Overall, the summary is quite good and thorough.
      (Obviously there are also some inaccuracies, as you’ve never actually built anything like this, but there didn’t appear to be anything very wrong)

      Most important thing to remember (for all of you):

      You should try to clearly separate (in your head!) the data and the presentation.

      For example:

      – User (has id, name, email address, type (admin/normal))
      – Food (has id, name, expiration date, average rating)
      – Rating entry (has user id, food id, rating number and timestamp)

      And now we can have various “screens” that show this data in many different ways
      – Admins show list of all foods, with option to add/edit/delete
      – Admins see list of users, can add/edit/delete
      – All users see list of foods
      – All users can give rating to food
      – All users can see foods they’ve rated, and change the rating
      – When admin is viewing the list of foods, expired or soon-to-expire foods are highlighted.

  • Joel L 16:42 on April 7, 2011 Permalink |
    Tags: homework   

    @Brent – Don’t forget your task. Also, I suggest you do it as soon as possible, as it’ll be much harder to recall everything later.

  • Joel L 22:37 on April 4, 2011 Permalink |
    Tags: homework   

    (Re-)learn this https://developers.facebook.com/docs/reference/fql/

    Also, this http://fkingtiny.com/4m
    These are the slides I’ve sometimes used. The last few slides contain new and useful (ie.: required) things about SQL. Doesn’t have a lot of explanations, but Google will help you.

    Search for stuff like “sql beginner tutorial” and read and read and read.
    You need to develop an understanding of how relational databases work, and how to write SQL queries (like you did last thursday using the Facebook widget).

    Understand how to SELECT, INSERT and UPDATE data.

    Point is — if you prepare for the lessons, we’ll advance quicker, and you’ll actually get to build something cool. If not, all your time will be spent learning the very basics.

    (note: you can’t INSERT/UPDATE stuff using the facebook-sql-widget, as they don’t allow it.)

    • Brent 18:30 on April 6, 2011 Permalink | Log in to Reply

      Küsimus, et need tabelid, kust kohast SQL mulle selle info toob(või mida ma saan mainpuleerida), kus võimalikes kohtades saab see tabel olla, ma siis mõtlen, et Kas neti lehekülg, Excel või muu selline?

      • Joel L 20:34 on April 6, 2011 Permalink | Log in to Reply

        Tavaliselt on mingi database serveri tarkvara, nt MySQL, MSSQL (Microsoft SQL server), PostgreSQL jooksmas, mis reaalselt andmeid hoiab.

        See võib olla nt enda masinas, või kuskil cloud’is (e mõnes suvalises serveris kuskil internetis).
        Nt Uniserver, mis arvutiklassi masinates jookseb ja mida PHP jaoks kasutasite, sisaldab ka MySQL serverit.

        Aga SQL iseenesest on standartne (kuigi eri serveritel võivad olla erinevad lisavõimalused etc) keel päringute tegemiseks — 
        seetõttu kasutabki nt Facebook SQL-i ühe võimalusena oma API kasutamiseks – teatud inimesed on sellega juba tuttavad.

        Sisuliselt võivad siis andmed olla salvestatud paljudel erinevatel meetoditel. Võivad olla “reaalsed” tabelid (nagu näiteks mu slaididel näited, e MySQL), või ka mingi abstraktsem andmekogu.

        itgs.elevantstudios.com lehe facebooki-widget töötab põmst nii, et

        1. Sina kirjutad query, vajutad “run query”
        2. Veebileht (php) saadab sinu query Facebooki serverile
        3. Facebook saadab vastuse veebilehele
        4. Veebileht näitab vastuse andmeid ilusti tabelis

        On umbes arusaadav vastus?

  • Joel L 20:08 on March 30, 2011 Permalink |
    Tags: homework   

    And revise http://itgs.elevantstudios.com/guide/

  • Joel L 20:05 on March 30, 2011 Permalink |
    Tags: homework   

    For late-night people. Re: “Create BaceFook and TouYube” 

    Using your brains, and the knowledge acquired from the Databases chapter from your books — 

    Think of an interactive/dynamic website you use often (rate.ee, Facebook, Gmail), and try to imagine the data model that’s used behind the scenes.

    This is the basis of all things internet. Don’t be lazy.


    Example – Youtube.
    (The following is a simplified version of things. And only an educated guess)



    • belongs to video
    • has author
    • has text, and time of creation


    • identified by username
    • has email address, password, etc

    Regarding the video view count — could be stored as a number (and has +1 added every time somebody presses play)
    But this would allow bots to repeatedly load a video, and have the view count be very high, without the video actually being popular.
    So YouTube must store every video view — for example:

    • video key (dQw4w9WgXcQ)
    • ip address
    • time

    Now we can ignore repeated views from the same ip address, and it’s much harder to cheat the system.

Compose new post
Next post/Next comment
Previous post/Previous comment
Show/Hide comments
Go to top
Go to login
Show/Hide help
shift + esc