Birdmansplace Posted April 5, 2020 Share Posted April 5, 2020 Some one from here helped me create this and i have added to it. Since i have updated my server everything works now except this code. Any help would be great. <?php include("../../db_inc.php"); // define HOST, USERNAME etc $db = new mysqli(HOST,USERNAME,PASSWORD,'roundrobin'); $sql = "SELECT result_id , round_no , roper_id , roper , heeler_id , heeler , time FROM result t INNER JOIN RRroper r ON t.roper_id = r.sid INNER JOIN RRheeler h ON t.heeler_id = h.sid ORDER BY round_no, roper_id"; $output=''; $res = $db->query($sql); $currRound = 0; while (list($resid, $round, $rid, $roper, $hid, $heeler, $time) = $res->fetch_row()) { if ($round != $currRound) { if ($currRound) { // end previous form $output .= "</table></fieldset> <input type='submit' name='btnSub' value='Submit Round'></form></div>\n"; } // start new form for round $output .= "<div class='form'><form method='post' action='roundrobin_updt.php'> <fieldset><legend id='$round'>Round $round</legend> <table border='1'> <tr><th>#</th><th>Header</th><th>Heeler</th><th>Time</th></tr>\n"; $currRound = $round; } $output .= "<tr><td class='ctr'>$rid</td><td>$roper</td><td>$heeler</td> <td class='ctr'><input type='text' name='time[$resid]' value='$time' size='8'></td></tr>\n"; } $output .= "</table></fieldset> <input type='submit' name='btnSub' value='Submit Round'></form></div>\n"; ?> <html> <head> <script type="text/javascript"> jQuery(document).ready(function($) { // Hook up the current state to the nav bar $('.page-navigation').onePageNav(); }); </script> <?php ini_set("display_errors", "10"); error_reporting(E_ALL); include("../../dbinfo.php"); $con = mysqli_connect($host,$username,$password); mysqli_select_db($con, $database7) or die( "Unable to select database"); // Retrieve data from database $sql="SELECT * FROM $tbl_name13 ORDER BY sid DESC LIMIT 1 "; $result=mysqli_query($con, $sql); while($rows=mysqli_fetch_array($result)){ ?> <title>RR <?php echo $rows['d1header']; ?></title> <link rel='stylesheet' type='text/css' href='../../tracklog.css'> <style type="text/css"> body { font-family: sans-serif; font-size: 12pt; background-color:#666; } table { margin-left: auto; margin-right: auto; width: 90%; /* border-collapse: collapse; */ } th { color: black; background-color: #369; padding: 5px 3px; } td { background-color: white; font-family: sans-serif; font-size: 12pt; padding: 0 3px; color: black; t } td.ctr { background-color: #ccc; text-align: center; width: 100px; } div.form { background-color: #CCC; margin-bottom: 10px; margin-left: auto; margin-right: auto; padding: 5px; width: 900px; text-align: center; } legend { padding: 3px; background-color: #369; color: white; } fieldset { text-align: left; } input[type='text'] { text-align: right; } h1 { text-align: center; } </style> </head> <body> <div id="top"></div> <h1><?php echo $rows['d1header']; ?></h1> <?php } ?> <?php // close connection mysqli_close($con); ?> <scroll class="site-navigation page-navigation1"> Quick Scroll <ul class="menu"> <li><a href="#top">R1</a></li> <li><a href="#2">R2</a></li> <li><a href="#3">R3</a></li> <li><a href="#4">R4</a></li> <li><a href="#5">R5</a></li> <li><a href="#6">R6</a></li> <li><a href="#7">R7</a></li> <li><a href="#8">R8</a></li> <li><a href="#9">R9</a></li> <li><a href="#10">R10</a></li> </ul> </scroll> <h1>Round Robin Event</h1> <div> <?php =$output ?> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
sanram123 Posted April 5, 2020 Share Posted April 5, 2020 Quote $sql = "SELECT result_id , round_no , roper_id , roper , heeler_id , heeler , time FROM result t INNER JOIN RRroper r ON t.roper_id = r.sid INNER JOIN RRheeler h ON t.heeler_id = h.sid ORDER BY round_no, roper_id"; in this statement, is it supposed to be "FROM result t" or should it be "FROM result" ? Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted April 5, 2020 Share Posted April 5, 2020 @sanram123 the t, the r, and the h are table alias names and belong where they are shown. @Birdmansplace what symptom or error are you getting that leads you to believe something isn't working? you need to provide information about what you saw in order to narrow down the possibilities. also, why do you have two completely different sets of database connection code? are both of those on the same page or is the posted code for two separate pages? your database connection code should be in a separate .php file that you 'require' when needed and each page should only make one database connection. Quote Link to comment Share on other sites More sharing options...
Birdmansplace Posted April 5, 2020 Author Share Posted April 5, 2020 Thanks for your input. The first "page" of code was from someone else and its easier for me to follow making another db connection to get other data and display it differently. My ability to code is very basic and the ability to code both sets together is something i just cant wrap my head around. My code is a mess and spread out over many files but i break code up so i can follow it better. Late last night i read and re-read the code and i finally figured out why it wasn't displaying anything. The last <?php?> tag at the very end i change to <?php and should have just left it at <?. I deleted the php tag and it worked. This code is apart of a project i took on for my inlaws horse arena to make webpage based event log for competitions. Thankfully i am almost done changing the code that i wrote to mysqli. For anyone who wants to know/see more about this can check this out and once i am done i will update new files to https://sourceforge.net/projects/php-event-tracklog/ Quote Link to comment Share on other sites More sharing options...
Barand Posted April 6, 2020 Share Posted April 6, 2020 I have just tried your first piece of posted code that "doesn't work" and it produced this for all 10 rounds ... So what is it that "doesn't work"? Your second piece of code (extract below) ... $sql="SELECT * FROM $tbl_name13 ORDER BY sid DESC LIMIT 1 "; $result=mysqli_query($con, $sql); while($rows=mysqli_fetch_array($result)){ ?> <title>RR <?php echo $rows['d1header']; ?></title> <link rel='stylesheet' type='text/css' href='../../tracklog.css'> <style type="text/css"> body { font-family: sans-serif; font-size: 12pt; background-color:#666; } table { margin-left: auto; margin-right: auto; width: 90%; /* border-collapse: collapse; } th { ... has a query that is impossible decipher what it does. It also outputs the HTML header info in its while loop! I didn't even try to run it. 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.