Hey guys, I need example of simple site that stores registration of students and for each student shows what class can he/she go depend on what college they are registered to, so its bassicly just words and everything static.

The registration page and database is not problem, but checking to see what college is loged student, and to display to him different classes is bit a problem to me.

I am not looking for someone to code it for me, just if there are already some examples I will appreciate it.

Thanks in advance

Recommended Answers

All 18 Replies

not going to get much help with that question

nobody wants to do your homework
google it yourself

then for what is this forum? you just post words or what?

what difference makes if its for job or homework? I am student not bussines man ^^

and I said I dont need whole thing, I am quite good with sql and basic stuff, I just need code to check student and display him class based on what college he is in, I guess that is 5 minute work for pros, and u was writing and giving me bad reputation for 5 minutes probably ^^

This forum is to HELP people. The support here is done by REAL people who do it for FREE. And your reply shows how LIMITED you are. No one is going to make your homework for you, so just stop your whining already.

Member Avatar for diafol

@filipgothic

Please read the site guidelines with regard to forum decorum.
Also please take the time to read this vital post:

http://www.daniweb.com/web-development/php/threads/435023/read-this-before-posting-a-question

We are prepared to help those who help themselves. There should be no 'sense of entitlement' to requests for help. Please post any code that you already have or code that doesn't work and we can point you in the right direction.

Ok, nothing to see here folks... :)

    <?php
    include('config.php');
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="Style" />
            <title>List of users</title>
        </head>
        <body>
            <div class="header">
                <a href="<?php echo $url_home; ?>"><img src="<?php echo $design; ?>/images/logo.png" alt="Members Area" /></a>
            </div>
            <div class="content">
    This is the list of members:
    <table>
        <tr>
            <th>Id</th>
            <th>Predmet</th>
            <th>Broj polaznika</th>
        </tr>
    <?php
    //We get the IDs, usernames and emails of users
    $req = mysql_query('select id, prdmet, broj_polaznika from FIT');
    while($dnn = mysql_fetch_array($req))
    {
    ?>
        <tr>
            <td class="left"><?php echo $dnn['id']; ?></td>
            <td class="left"><?php echo htmlentities($dnn['predmet'], ENT_QUOTES, 'UTF-8'); ?></a></td>
            <td class="left"><?php echo htmlentities($dnn['broj_polaznika'], ENT_QUOTES, 'UTF-8'); ?></td>
        </tr>
    <?php
    }
    ?>
    </table>
            </div>
            <div class="foot"><a href="<?php echo $url_home; ?>">Go Home</a> - <a href="http://www.webestools.com/">Webestools</a></div>
        </body>
    </html>

I have all I need, all I asked for is code that check user, and if user is for example from college of information science, display to him several classes, and if is student from medicine, display some other classes, and thats it, other than that I am good.

I have all I need

8 letter word representing bovine excrement

bloody students
havent learned enough yet to know, what anybody who gave a damn enough to help, would need to do that help

not made any effort

the school finals next week, NOT our problem. If you had done any work all year, you would be done now.

example of how to ask

search yourself

commented: they never learn... +2

what are you talking about, my school finish at end of the year, and I know most of stuff for my class, I am kinda advanced student, what I am asking is bonus for students, I want to do it, and I asked for some examples, and not to do whole thing for me, I see you posted me some example, and I am thankful for that, its not that hard to copy paste link, but people would rather talk about it, then do something usefull for community, but well thats fine as long there is at least one that will come sooner or later and provide some help

thanks again...

Member Avatar for diafol

I've got a bucket of cold water on standby...

You should have a link table. Here's a store-product example

stores: store_id (PK) | storename
products: product_id (PK) | productname
store_products: store_id | product_id (link table should have UNIQUE compound key)

SELECT p.product_id, p.productname FROM products AS p 
    INNER JOIN store_products AS sp ON p.product_id = sp.product_id
    WHERE sp.store_id = 5

Not tested.

thanks for reply, but what I need is more like php code for example

if (loged user is from IT) show him computer architecture, web design...

if (loged user is from Sport) show him basketball etc

and IT can't see basketball, and sport can't see web design, that is few lines of code which I don't know

most of examples I have are based on seassons, so if user is loged in, show him member area and if its not dont show him, simple as that, but I need more options available

Member Avatar for diafol

If your data is fine, then the accompanying php should be easy. Based on my SQL with the store-product example...

SELECT p.product_id, p.productname FROM products AS p 
    INNER JOIN store_products AS sp ON p.product_id = sp.product_id
    WHERE sp.store_id = 5

When you loop over the results, you can create checkboxes or even a multiselect listbox. For the checkboxes... (using PDO)

$output = array();
$result = $stmt->fetchAll();
foreach($result as $row)
{
    $output[] = "<label><input type="checkbox" name="products[]" value="{$row['product_id]}" /> {$row['productname']}</label>";
}
...
<!-- In your form area-->
<?php echo implode("<br />", $output);?>

that is nice idea, but it would be probably too much, I need kinda simple words only, list of classes that student can watch, maybe only load some page with that list depend on what college student choose on registration I have for example on registration

Name
Email
password
College

and database for those things, and now when user log in if he choosed on registration before IT as college, to display him IT page, on registration I can make dropdown menu for college, with 3,4 options, and based on choosen option display different pages to registered students

so I need that code that checks user information, other than that I have eveything, registration code, database etc

Member Avatar for diafol

I believe that's what the code does. You don't have to use checkboxes, it can be just a list (ul/li).

I am kinda advanced student

This is pretty basic stuff. There are thousands, 10s of thousands of examples online.

I am advanced for my class, but we are not pros, we are students, so dont be hard on me...

I was looking on wrong sites for example then, I have plenty of register forms and lots of php code to keep database secure and compliceted stuff, but I can't find this simple one

your example for products is close, but I don't need to make users to chose anytime what list is going to be displayed, I need one list whole time for one student and it will never change, its static, just need to make difference betwen 2,3 types of students, so 2,3 lists

and database is simple, it should hold only username, password, email, and college, same on register page, and when user login this is where I need help, I need code that checks college and display page for student, example if (college=IT) displat IT.html because its simple page static no need for php unless I want some security so only students from IT can see it but that is not soo important atm, need only loged in student to be redirected to right page, security is not that important

Member Avatar for diafol

I don't think you understood my post. The store-product is pretty much the same as your user-college-courses

user: user_id... college_id
colleges: college_id, collegename...
courses: course_id, coursename...
college_courses: college_id, course_id

SELECT c.coursename FROM user AS u INNER JOIN college_courses AS cc ON u.college_id = cc.college_id INNER JOIN courses AS c ON cc.course_id = c.course_id WHERE u.user_id = 7 

That gives a list of all the available courses for user #7

BTW, do not have a datatype of varchar for the college field in 'users' - this should be a related field as integer to the colleges table.

aright I get part of it

but not ID part, do I need to add for every new user a page that will do u.user_id = 1,2,3,4 or that is done auto?

you are using sql that is above my level, u cc and those are commands that I don't understand

Member Avatar for diafol

u, c, cc are known as aliases and are shorthand for tablenames (or sometimes fieldnames, depending on context).

This would be the full SQL (no aliases)

SELECT courses.coursename FROM users INNER JOIN college_courses ON users.college_id = college_courses.college_id INNER JOIN courses ON college_courses.course_id = courses.course_id WHERE users.user_id = 7

When a user logs into your site, then you store the user_id in a session variable. When the user enters the 'courses' page, you just run the following...

SELECT c.coursename FROM user AS u INNER JOIN college_courses AS cc ON u.college_id = cc.college_id INNER JOIN courses AS c ON cc.course_id = c.course_id WHERE u.user_id = $_SESSION['user_id']

You wouldn't normally place the var directly into the SQL though, you'd bind this as a parameter using PDO (or mysqli).

alright I got it now, thanks for your help, I will mark this as solved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.