I have a database that contains names, places, and several other fields.
ID - University Name - Group Name - Website - Email
Now I would like to have a way so that I can choose 'University Name' and have it display all the groups that are a part of that university. Or vice versa. What would you suggest for this?
Thats part 1.
Part 2 coming soon.
Thank you for all your help, I really appreciate it.
Creating a PHP interface that hits a mySQL backend
Moderator: General Moderators
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: Creating a PHP interface that hits a mySQL backend
I would suggest learning XHTML and PHP. 
Honestly, thats a pretty simple request, so I am not sure what your looking for:
That is the gist of it anyways -- although you'd be better off using PKID's instead of university names when indexing a single record.
Honestly, thats a pretty simple request, so I am not sure what your looking for:
Code: Select all
<?php
$uniname = $_GET['uniname'];
$sql = 'SELECT * FROM table WHERE uniname = "'.$uniname.'"
// TODO: Feed above SQL to mysql_query
?>
Code: Select all
<html> <body> <select name="uniname"> <option value="UND">UND</option> <option value="MIT">MIT</option> <option value="McGill">McGill</option> </select> </body></html> - aaronhall
- DevNet Resident
- Posts: 1040
- Joined: Tue Aug 13, 2002 5:10 pm
- Location: Back in Phoenix, missing the microbrews
- Contact:
Re: Creating a PHP interface that hits a mySQL backend
If groups has a many-to-one relationship to universities, your schema should look something like
Code: Select all
CREATE TABLE universities (
id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
name varchar(255) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE groups (
id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
universityID int(11) UNSIGNED NOT NULL,
name varchar(255) NOT NULL,
PRIMARY KEY (id)
);
SELECT * FROM `groups` WHERE universityID = {{some university id}};