sportsguy Posted June 26, 2008 Share Posted June 26, 2008 I am trying to update a standings script. I need to add some MySQL code that adds a division whenever a conference is added. I need the confname and conforder to be inserted into both sportsdb_conferences and sportsdb_divs tables. case 'editconferences': $numconfs = count($_POST['confid']); for ($i=0;$i<$numconfs;++$i) { $confname = htmlspecialchars($_POST['confname'][$i], ENT_QUOTES); $confid = intval($_POST['confid'][$i]); $conforder = intval($_POST['conforder'][$i]); $query = "UPDATE ".$db_prefix."sportsdb_conferences SET confname = '$confname', conforder = $conforder WHERE confid = $confid LIMIT 1"; mysql_query($query) or die ("Error in query $query"); print "<p>Conferences updated.</p>"; } // Add a new conference if there has been a name entered $confname = htmlspecialchars($_POST['confname'][$i], ENT_QUOTES); if ($confname <> "") { $conforder = intval($_POST['conforder'][$i]); $query = "INSERT INTO ".$db_prefix."sportsdb_conferences (confname,conforder) VALUES ('$confname','$conforder')"; mysql_query($query) or die ("Error in query $query"); print "<p>Conference added as well!</p>"; } print "<p><a href=\"$update_page\">Back</a></p>"; Please help. Thanks! Quote Link to comment Share on other sites More sharing options...
sportsguy Posted June 26, 2008 Author Share Posted June 26, 2008 I though I might be getting somewhere with modifying the query as: $query = "INSERT INTO ".$db_prefix."sportsdb_conferences (confname,conforder) VALUES ('$confname','$conforder') AND ".$db_prefix."sportsdb_divs (divname,divorder) VALUES ('$divname','$divorder')"; No luck! Help is appreciated. Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted June 26, 2008 Share Posted June 26, 2008 I dont think you can do 2 separate queries at the same time. Just split them up into 2. And I dont think <> is a valid checker. do '!=' (not equal to) also, add single quotes around the variables(like "where id='$id', not "where id=$id") and also, on your die statement after a query, make it "or die(mysql_error());" that'll help you with what the problem is. And I'm confused with "UPDATE ".$db_prefix."sportsdb_conferences" what is db_prefix? I dont see it declared as anything. I don't think you need multiple different tables for this kind of thing. Quote Link to comment Share on other sites More sharing options...
sportsguy Posted June 26, 2008 Author Share Posted June 26, 2008 I did not write the script. It is a stand alone Sports Standings code form http://www.theblog.ca/sports-league-standings. You can ignore the ".$db_prefix." prefix to table name. That is for my integration into CMS. I contacted the author to inquire removing of the Conference because it is not necessary for my league and confuses the admin process. At the present time, I have to duplicate the adding of the Division Name as Conference and Division. I was told, On the admin side of things, you could add some MySQL code that adds a division whenever a conference is added (under case ‘add’: in the management script). This is quite similar to what you’ve already done, but will help to automate things in the future. On the display side of things, you would just have to treat conferences as divisions. In other words, the index page would still list the conferences, but you would just change it to say that it lists divisions. Then, since each conference of yours contains exactly one division, make the conference view look like a division view (remove the conference title and make the division name print the conference name instead). Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted June 26, 2008 Share Posted June 26, 2008 If you can't edit the script and tell us if the help worked, why even ask? Quote Link to comment Share on other sites More sharing options...
sportsguy Posted June 26, 2008 Author Share Posted June 26, 2008 You are missing the point. I am eliminating a step in the process because it is not necessary. As previously stated, "I need (help) to add some MySQL code that adds a division whenever a conference is added." I need to assistance to INSERT data into a second table on submit, inserting into both sportsdb_conferences and sportsdb_divs tables. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.