Jump to content

aaarrrggh

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

aaarrrggh's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [!--quoteo(post=382918:date=Jun 12 2006, 12:47 PM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ Jun 12 2006, 12:47 PM) [snapback]382918[/snapback][/div][div class=\'quotemain\'][!--quotec--] can you do me a flavor and post your query string, query command, and all that stuff, that leads up to this if statement? [/quote] No probs: $check_for_password = "SELECT `teams`.idteams, `leagues`.league_password FROM `leagues` INNER JOIN `teams` ON (`leagues`.league_id = `teams`.league_id) WHERE (`teams`.idteams = $team_id_no)"; $do_check_for_password = mysql_query($check_for_password) or die(mysql_error); while ($row = mysql_fetch_array($do_check_for_password)){ $league_password_check = $row['league_password']; }
  2. [!--quoteo(post=382892:date=Jun 12 2006, 11:54 AM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ Jun 12 2006, 11:54 AM) [snapback]382892[/snapback][/div][div class=\'quotemain\'][!--quotec--] okay according to the link: i see the int 0 which would explain $blah==0 but it also says string "0" so doesn't that mean that $blah==0 would do the same thing as what he has now with $blah=="0" ? [/quote] Hmm. Yeah, how come my code was always executed to begin with though? I mean, if ($league_password_check == 0){ all other code goes here } Should not be executed if there is something other than '0' inside the $league_password_check variable should it? If I'm holding a md5 hash inside that variable, surely it would test as true in the if statement?
  3. Hi, I've actually managed to 'solve' this problem as in my code now does what I want it to do, but I don't fully understand why it wasn't working in the first place, so I thought I would ask around to see if somebody can explain this to me. I have created a site that allows people to create their own leagues for the game 'pro evolution soccer'. I wanted league admins to be able to put a password on their league, so only people they know or want to join their league can do so. This is where the weirdness happened. The code seemed to be working fine for a while, then it suddenly allowed people to join even if a password had been set. Eventually, I found out where the problem lay and got it working, but I don't understand it properly. It turned out that the problem lay in the start of my [i]if[/i] statement. Here is the offending code: if ($league_password_check == 0){ all other code goes here } The $league_password_check variable was created by checking inside the database to see whether a password had been set. The field type inside mysql is a Varchar(). When a user creates a league, he gets to pick whether he wants a password setting. If the password is not set, the field is set to 0 inside mysql. If it is set, the password is set to an Md5() hash. The code was always executed, regardless of the value of the $league_password_variable. I even echoed the value inside the variable, and it was still being executed even when the value wasn't zero. Anyway, when I changed the code to this: if ($league_password_check == '0'){ all other code goes here } It suddenly worked how I wanted it to. The problem is I don't really understand why. Can somebody help clarify this for me? Hope I've given all the details you need. Thanks in advance :D **Edit: I know... I've posted this in the wrong part of the forum. That's what having 15 windows open in firefox at the same time can do to you lol. Sorry about that...
  4. [!--quoteo(post=361669:date=Apr 4 2006, 02:15 PM:name=redbullmarky)--][div class=\'quotetop\']QUOTE(redbullmarky @ Apr 4 2006, 02:15 PM) [snapback]361669[/snapback][/div][div class=\'quotemain\'][!--quotec--] to an extent. holding a table column to a width would normally cause the info in the cells to continue on a new line, but depends. if i was setting up a league table personally, i would change your code by removing the 'width' property from your football team name column but leaving the rest alone. you've set the width of the table to 420 or something and yet all your column widths don't add up to much more than 200. removing the width property from the largest column (ie, the team name) will at least prevent other problems in the future. [/quote] I tried removing the width property from the team column, and it's worked perfectly. Is that because this now becomes the most 'flexible' column, if you know what I mean? Like... any available empty space is allocated to this column first because there's no explicit 'width' property defined? Is that why this works? Thanks for the help by the way, the tables are looking a lot better now :)
  5. Thanks guys. I did what redbull said, and it seems to be looking a lot better now. Just out of interest, would using <TD width="x"> restrict the size of the table even when data comes through php that is too big for the table cell? Is there anyway to stop it from resizing? This isn't a problem to me right now, but it's something I know I might need to know in the future. Thanks for the help once again :)
  6. Hi, I'm currently trying to display some php output inside a html table. All the data is printing just as I want, except that the table itself seems to resize and reshape according to what data comes out of php. Is there any way for me to force the table and all table cells to stay exactly the same size no matter what? You can see the table I'm talking about by viewing this temporary site: [a href=\"http://www.itr.org.uk/home.php?page_id=tables.php&showtable=33\" target=\"_blank\"]http://www.itr.org.uk/home.php?page_id=tab...hp&showtable=33[/a] As you can see right now, it doesn't look neat at all. Does anybody know how I can fix this?
  7. I'm a newbie to MYSQL, and have been struggling with this one select statement for the past two days now, and I just can't seem to get it right. I'm pretty sure I should be using 'LEFT JOIN', but I don't know how to execute it properly. I'm creating a soccer site for an online game that allows people to create their own leagues, and this select statement is meant to display all the teams in each league. Eventually it will need to display them in points order, then goal difference etc, but that's not the part that I'm worried about right now. Basically, I'm storing information in several different tables to make it easier to create the leagues themselves. I have a users table with all the user info in it, a 'teams' table, which stores the information about each assigned team, a 'team names' table which is used to store the actual names of the teams, a 'leagues' table, which is used to store information about assigned leagues, and finally a 'league rankings' table, which stores information about how well each team is doing in their respective league (points, goals scored, games won etc). The select statement I've created so far looks like this: "SELECT users.username, team_names.team_name FROM users, team_names, teams, league_rankings, leagues WHERE users.user_id = teams.user_id AND team_names.team_names_id = teams.team_names_id AND league_rankings.idteams = teams.idteams AND leagues.league_id = 33 AND teams.league_id = leagues.league_id;" (Where leagues.league_id is the actual league I want to look at, in this case being league 33). This seems to work fine in showing me all teams in a particular league that have been assigned a user, but I want to also be able to show the teams that have no user assigned too. Basically, the way I'm working it is that the teams exist inside the league table first, and a player then comes along and 'owns' that team. Does anyone here know how I might be able to get all the teams in a particular league to show up? Sorry if I've not given enough information about my database structure; I can elaborate on this if that would help. Please help me with this guys. I'm going mad here!
  8. Well I think I might have got it now. Not sure, but it's looking that this so far in the database designer program I'm using: [img src=\"http://img147.imageshack.us/img147/5043/ploppy4hj.png\" border=\"0\" alt=\"IPB Image\" /]
  9. Yeah, I suppose. I've taken on quite a big project really seeing as it's the first time I've ever done anything like this. The main thing I really need to know is how I can allow users to create new league tables using php/mysql. I've thought about this, and I think it might be possible to have one table with information about what league people are in and the name of the leauge, and another table that holds all the points information etc. I just don't know whether this is a good way of doing it or not, like, will I find the site slows down a lot when I get a larger number of people creating leagues on there? I'm also going to have to work out the fixture list, which I can already see is going to cause me headaches...
  10. I'm also going to have to have a fixture list, that records all games played, the results of each match, and makes sure that people dont play eachother more than two times in any given season. Can anybody give me any advice?
  11. Hello there! I'm pretty new to php, and have been learning the basics over the last few weeks. I'm now trying to build a site for a football (soccer) game that allows users to create their own league system once they have registered. The problem I am having relates to the way I store information about the leagues in the MYSQL database. It's the first time I've really tried using MYSQL for anything slightly complex, and I'm struggling to get to grips with it at the moment. At the moment, I've set it up so I've got the following tables: CREATE TABLE assigned_leagues ( user_id INTEGER(10) UNSIGNED NULL, league_id INTEGER UNSIGNED NULL, INDEX assigned_leagues_index(user_id, league_id) ); CREATE TABLE leagues ( league_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, league_admin_user_id INTEGER(10) UNSIGNED NOT NULL, name VARCHAR(32) NULL, created_on TIMESTAMP NULL, capacity INTEGER UNSIGNED NULL, active INTEGER UNSIGNED NULL, PRIMARY KEY(league_id), INDEX leagues_index(league_admin_user_id) ); CREATE TABLE reg ( reg_id INTEGER(10) UNSIGNED NOT NULL, des_username VARCHAR(20) NOT NULL, pword VARCHAR(32) NOT NULL, email VARCHAR(75) NOT NULL, confirm VARCHAR(32) NULL, PRIMARY KEY(reg_id) ); CREATE TABLE super_league_1 ( league_id INTEGER UNSIGNED NOT NULL, user_id INTEGER(10) UNSIGNED NOT NULL, team VARCHAR(32) NULL, played INTEGER UNSIGNED NULL, won INTEGER UNSIGNED NULL, drew INTEGER UNSIGNED NULL, lost INTEGER UNSIGNED NULL, goals_for INTEGER UNSIGNED NULL, goals_against INTEGER UNSIGNED NULL, goal_difference INTEGER UNSIGNED NULL, points INTEGER UNSIGNED NULL, season INTEGER UNSIGNED NULL, PRIMARY KEY(league_id) ); CREATE TABLE users ( user_id INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT, username VARCHAR(20) NOT NULL, pword VARCHAR(32) NOT NULL, email VARCHAR(50) NOT NULL, priv INTEGER(10) UNSIGNED NULL, reg_date TIMESTAMP NULL, PRIMARY KEY(user_id) ); CREATE TABLE user_stats ( iduser_stats INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, user_id INTEGER(10) UNSIGNED NOT NULL, overall_games_played INTEGER UNSIGNED NULL, overall_games_won INTEGER UNSIGNED NULL, overall_games_lost INTEGER UNSIGNED NULL, overall_goals_scored INTEGER UNSIGNED NULL, overall_goals_conceded INTEGER UNSIGNED NULL, best_winning_run INTEGER UNSIGNED NULL, worst_losing_run INTEGER UNSIGNED NULL, biggest_win INTEGER UNSIGNED NULL, biggest_defeat INTEGER UNSIGNED NULL, leagues_won INTEGER UNSIGNED NULL, cups_won INTEGER UNSIGNED NULL, PRIMARY KEY(iduser_stats), INDEX user_stats_index1557(user_id) ); I'm currently trying to do this so that when a user selects 'create new league' inside the site, PHP will create a new table to represent that league inside MYSQL. The 'Super_league_1' is an example of what these tables will look like. The main thing I want to work out at the moment is the way I should be sorting my information in mysql. I've got a feeling that I'm making things a lot harder for myself than I need to, but I'm not sure how to rectify this. Should I have to create a new table in mysql when users create a new league table, or should I be able to do this another way? Any other advice would be really well appreciated. I'm new to PHP, but I've enjoyed doing this so far, and I'd love to learn any better techniques from people out there that are more experienced than I am. You can view what I've done so far on the site at a temporary address here: www.itr.org.uk/home.php The registration system is up and running now :) Please help if you can!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.