Jump to content

sstoveld

Members
  • Posts

    80
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

sstoveld's Achievements

Member

Member (2/5)

0

Reputation

  1. that didnt seem to work, the team_id is not getting assigned to the links, and it still lists about many entries for each team (one entry for each player on the team) edit: but it did fix my resource id #4 problem
  2. sorry for a bump so soon, dont see an option to edit my post... anyway, i edited my code so the standings page on my site doesnt actually show an error in my mysql, but the links still are missing the team_id=# at the end... here's the code i am currently working on: <?php $querystandings = mysql_query('SELECT * FROM standings ORDER BY points DESC'); if (!$querystandings) { exit ('<p>Error in query.'. mysql_error().'</p>'); } while ($row = mysql_fetch_array($querystandings)) { echo('<tr><td>' . '<a href="teams.php?team_id='.$row['team_id'].'"> ' . $row['team'] . '</a></td><td>' . $row['games_played'] . '</td><td>' . $row['wins'] . '</td><td>' . $row['losses'] . '</td><td>' . $row['ties'] . '</td><td>' . $row['points'] . '</td></tr>'); } ?> edit: for some reason, my 2nd post has a modify option, but not the first
  3. sorry for the lack of info i encountered another problem and forgot i already had this one going link to the new thread: http://www.phpfreaks.com/forums/index.php/topic,280121.0.html i posted a lot more info in the new thread and the login info if possible, could a mod merge the two threads? thanks
  4. hey guys, having a minor (i think) problem here that i havent been able to figure out. long story short, im building a hockey stat tracking site for a local hockey league around here. my problem is, i am trying to run a query using php, but the value getting returned is Resource id #4 instead of what it is supposed to be. i read around and found people saying you need to use mysql_fetch_array, which is what i am doing. let me start by posting my code: <?php $querystats = mysql_query('SELECT * FROM stats ORDER BY team_id'); $statsresult = mysql_query($querystats); if (!$statsresult) { exit ('<p>Error in query.'. mysql_error().'</p>'); } while($row = mysql_fetch_array($statsresult)) { echo $row['team_id']; print_r($team_id); $querystandings = mysql_query('SELECT * FROM standings ORDER BY points DESC'); if (!$querystandings) { exit ('<p>Error in query.'. mysql_error().'</p>'); } while ($row = mysql_fetch_array($querystandings)) { echo('<tr><td>' . '<a href="teams.php?team_id='.$row['team_id'].'"> ' . $row['team'] . '</a></td><td>' . $row['games_played'] . '</td><td>' . $row['wins'] . '</td><td>' . $row['losses'] . '</td><td>' . $row['ties'] . '</td><td>' . $row['points'] . '</td></tr>'); } } ?> i believe the problem is the $querystats. here's what my table structure looks like: here's a link to my site: http://gamera.caset.buffalo.edu/~sstoveld/DMS315/projects/final/standings.php you can login with: username: test password: test the problem is on the standings page, if you hover over a team name and look at where the link directs to, it ends with team_id= i need to get the proper team_id in the link, which is where im hoping someone can help me. ive been looking through this trying many different things that i cant seem to get to work. if my above code is completely wrong with using the $querystats query, how can i get this to work. originally the $querystats query wasnt there, and only the $querystandings query was being used, but the links wouldnt work because i am not selecting the team_id from the stats table. when i modify the $querystandings query to left join on stats, the loop goes through and adds about 25 entries per team, which is not what i want. if you need any more info, please ask, i cant figure this out
  5. hey guys, having an issue here with my code... here it is: $select = mysql_query("SELECT * FROM stats LEFT JOIN standings ON standings.id = stats.team_id WHERE stats.team_id = '$team_id' ORDER BY stats.points DESC")or die(mysql_error()); what is the problem with this piece of code? here is a link to where my problem is on my site: http://gamera.caset.buffalo.edu/~sstoveld/DMS315/projects/final/standings.php when you click a link, it goes to the page for that team, but the table does not get populated with the data i am trying to put in there, it just stays blank if you need some more info, let me know, not sure if im forgetting anything. thanks for help in advance
  6. ah i figured it out. if anyone else has the same type of problem, this might help: <?php // Sort // $sort = $_GET['sort']; if ($sort == NULL){ $sort = "ranking"; } ?> <h2>Enemy List</h2> <table> <tr> <td><strong><a href="a3.php?sort=rank">Rank</a></a></strong></td> <td><strong><a href="a3.php?sort=fname">First Name</a></strong></td> <td><strong><a href="a3.php?sort=lname">Last Name</a></strong></td> <td><strong><a href="a3.php?sort=organization">Organization</a></strong></td> <td><strong><a href="a3.php?sort=comment">Comment</a></strong></td> </tr> <?php // Query the Database to select the entries in the list // $querylist = @mysql_query('SELECT * FROM enemylist ORDER BY '.$sort.';'); if (!querylist) { exit ('<p>Error in query.'.mysql_error().'</p>'); }
  7. right, but what im not getting is making my table headers into get variable links so the user can sort the table using them
  8. sorry to bump a post, but i dont quite understand how to do this
  9. sorry could you elaborate a bit, im pretty new to php and dont quite understand
  10. hey guys, ive got a small issue with my project here. i have an assignment to create an enemy list (like nixon's enemy list) using a database, and display it on the page. i have all that done, but i need to be able to let the user sort through the values by rank, first name, last name, organization, or comment. i believe what i need to do it make the table headers a link that the user can click which will sort it ascending or descending, problem is, im not sure how to do that... here's what i've got so far: <?php // Connect to the Database // $dbhost = '*****'; $dbuser = '*****'; $dbpass = '*****'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); // Select the Database // $dbname = '*****'; mysql_select_db($dbname); // Query the Database to select the entries in the list // $querylist = mysql_query('SELECT * FROM enemylist ORDER BY rank'); // Make an HTML table to hold the data for the list // ?> <h2>Enemy List</h2> <table> <tr> <td><strong>Rank</strong></td> <td><strong>First Name</strong></td> <td><strong>Last Name</strong></td> <td><strong>Organization</strong></td> <td><strong>Comment</strong></td> </tr> <?php while ($row = mysql_fetch_array($querylist)) { echo('<tr><td>' .$row['rank'] . '</td><td>' . $row['fname'] . '</td><td>' . $row['lname'] . '</td><td>' . $row['organization'] . '</td><td>' . $row['comment'] . '</td></tr>'); } ?> </table> can anyone lend a hand? thanks
  11. thank you for all your help! i am finally finished. i appreciate it. here's the final thing: http://gamera.caset.buffalo.edu/~sstoveld/a2.php i know its ugly, but im too tired to bother and make it look nice
  12. ahh thanks haha, got that all sorted out. im working on the country.php page now, but having issues... i keep getting this error: Fatal error: Cannot use object of type stdClass as array in /home/sstoveld/public_html/country.php on line 43 $s = mysql_query("SELECT * FROM Country WHERE Code ='$code' ORDER BY Name")or die(mysql_error()); while($row=mysql_fetch_object($s)){ // Fill the tables with the Data // ?> <table> <tr> <td><strong>Local Name:</strong></td><?php echo('<td>' . $row['LocalName'] . '</td>') ?> </tr><tr> <td><strong>Code:</strong></td><?php echo('<td>' . $row['Code'] . '</td>') ?> </tr><tr> <td><strong>Two Character Code:</strong></td><?php echo('<td>' . $row['Code2'] . '</td>') ?> </tr><tr> <td><strong>Continent:</strong></td><?php echo('<td>' . $row['Continent'] . '</td>') ?> </tr><tr> <td><strong>Reigon:</strong></td><?php echo('<td>' . $row['Reigon'] . '</td>') ?> </tr><tr> <td><strong>Surface Area:</strong></td><?php echo('<td>' . $row['SurfaceArea'] . '</td>') ?> </tr> </table> <?php } ?> line 43 would be the one with LocalName
  13. when i try that, i just get a blank page, no errors or anything :S is there something wrong with this piece of code? while ($row = mysql_fetch_array($queryasia)) { echo('<tr><td>' . '<a href="country.php?code=".$row['Code']."> ' . $row['Name'] . '</a></td><td>' . $row['Population'] . '</td><td>' . $row['GNP'] . '</td><td>' . $row['GovernmentForm'] . '</td></tr>'); }
  14. hmm im still not quite getting it. when i try this the link still reads out country.php?code=$code... how do i get the $code part to actually display the correct country code? // Query the Database to select Countries // $queryasia = mysql_query('SELECT * FROM Country WHERE Continent = "Asia" ORDER BY Name'); $queryeurope = mysql_query('SELECT * FROM Country WHERE Continent = "Europe" ORDER BY Name'); $queryna = mysql_query('SELECT * FROM Country WHERE Continent = "North America" ORDER BY Name'); $queryafrica = mysql_query('SELECT * FROM Country WHERE Continent = "Africa" ORDER BY Name'); $queryoceania = mysql_query('SELECT * FROM Country WHERE Continent = "Oceania" ORDER BY Name'); $queryantarctica = mysql_query('SELECT * FROM Country WHERE Continent = "Antarctica" ORDER BY Name'); $querysa = mysql_query('SELECT * FROM Country WHERE Continent = "South America" ORDER BY Name'); // Make an HTML table to hold the data for Asia // ?> <h2>Asia</h2> <table> <tr> <td><strong>Name</strong></td> <td><strong>Population</strong></td> <td><strong>GNP</strong></td> <td><strong>Government</strong></td> </tr> <?php while ($row = mysql_fetch_array($queryasia)) { echo('<tr><td>' . '<a href="country.php?code=$code">' . $row['Name'] . '</a></td><td>' . $row['Population'] . '</td><td>' . $row['GNP'] . '</td><td>' . $row['GovernmentForm'] . '</td></tr>'); } // Make an HTML table to hold the data for Europe // ?> and then once it takes you to the new page, how do i get it to show the correct information about the correct country?
  15. ok im starting to understand this a bit, but the problem is, there are about 250+ countries in the database, does that mean i would have to change each into a link manually? like i want the user to be able to click on any of the countries listed, which would take them to a page that shows the info about that country. example: http://flywheel.caset.buffalo.edu/315/world.php when the user click on say, Afghanistan, it takes them to this page: http://flywheel.caset.buffalo.edu/315/country.php?code=AFG do i have to create each link individually?
×
×
  • 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.