Ok, please bear with me as I have only begun to learn php and sql about 3 days ago. Since then I've done a few things which can be seen at http://www.uafclan.com. I've been doing tutorial after tutorial, reading page after page after page of code, and studying phpbb forums code to familiarize myself with it. I have most of the concepts down, though I'm still shaky with alot of it.
Here is my problem:
I used to have a coder for my gaming clan a few years ago, who created a php/sql website for us. After he left however, not knowing anything about php/sql, I deleted the database unknowingly. The database the site was using was the same as the forums were using. I had deleted the forums database, and there went the site one too.
Anyway, as I've been learning PHP and SQL lately, I've been stuck on trying to figure out how the other person did some of the things he did. I can't refer to the database because there is no database anymore, so I have to guess at what he was doing.
I tried doing the same thing, but somehow he seems to have database tables nested deeper than just one level or something, because nomatter what I try, I cannot duplicate what he did before.
I want to display a page with a list of users, along with their ranks, and name in the order from the highest rank to the lowest.
I also want to display a page that states what pacts we have with other gaming clans, their clan tag, clan name, clan url. I tried doing it the way he had it, but he had all the stuff in one table. I can't figure out how he did it. I finally got it working by making seperate tables for each pact, but I'd like to get it to work in one table like he did if I can.
Here is three bits of code he used. Could anyone tell me how he made the database tables for this? Please make a note, that I'm only posting one chunk. He posted these same chunks over and over, with only the type of pact or rank heierarchy changed in the code.
[u] Roster Example[/u]
$query_rs_juniors = "SELECT user_id, username, user_rank, user_image, rank_id, rank_title, rank_image FROM phpbb_9999users, phpbb_9999ranks WHERE user_rank = rank_id AND rank_value > 12 AND rank_value < 21 AND user_onleave = 0 ORDER BY rank_value ASC, username ASC";
$rs_juniors = mysql_query($query_rs_juniors, $conn_local) or die(mysql_error());
$row_rs_juniors = mysql_fetch_assoc($rs_juniors);
$totalRows_rs_juniors = mysql_num_rows($rs_juniors);
?>
[u]Ranks Page Example: [/u]
mysql_select_db($database_conn_local, $conn_local);
$query_rs_juniors = "SELECT rank_id, rank_title, rank_image FROM phpbb_9999ranks WHERE rank_value > 12 AND rank_value < 21 ORDER BY rank_value ASC";
$rs_juniors = mysql_query($query_rs_juniors, $conn_local) or die(mysql_error());
$row_rs_juniors = mysql_fetch_assoc($rs_juniors);
$totalRows_rs_juniors = mysql_num_rows($rs_juniors);
?>
[u]Relations Page Example:[/u]
mysql_select_db($database_conn_local, $conn_local);
$query_rs_mpp = "SELECT relation_tag, relation_name, relation_website FROM website_relations WHERE relation_type = 2 ORDER BY relation_name ASC";
$rs_mpp = mysql_query($query_rs_mpp, $conn_local) or die(mysql_error());
$row_rs_mpp = mysql_fetch_assoc($rs_mpp);
$totalRows_rs_mpp = mysql_num_rows($rs_mpp);
?>
I've made up a sketch of what I believe the database that my old designer created might have looked like, according to the php code in the files.
This is only a guess mind you. I am not sure what order it went in, but this seems to make the most sense. Either way he either had to have somehow nested the tables, or he was pulling from two different tables. Can someone take a look at this and help me figure out how I can duplicate what he did in my own database? Thanks.
website_relations <---TABLE
relation_type
mpp
relation_tag relation_name relation_website