Jump to content

Psycho

Moderators
  • Posts

    12,164
  • Joined

  • Last visited

  • Days Won

    130

Everything posted by Psycho

  1. Several issues in that code: 1. You should not use 'external' variables to create a while() loop. Use a while() loop to get one row at a time. Makes the code much, much simpler. What you have now could easily break if the values for $i or $j get modified incorrectly. Not to mention that variables with names like $i and $j provide no context as to what they hold. 2. No reason to call mysql_result() many times instead of just calling a mysql_fetch_ one time. As to your question it can be implemented many ways. You can create ONE form and have a submit button for each record which will pass the ID of the record to your edit page. Or, you can make a mini form for each record. Which one you go with will be determined by several factors. You also need to decide what 'value' is passed to the edit page (I'm assuming it is the fkey). Here is one example: <?php require('connect.php'); session_start(); $query = "SELECT fkey, projectid, paying, completionmonth, completiondate, personspecify, projecttitle, categories, tools, shortdescription, date, time FROM project WHERE projectstatus='Open'"; $result = mysql_query($query); $count = 0; $projectList = ''; while ($row = mysql_fetch_assoc($result)) { $count++; $projectList .= "<br>{$count}<br>\n"; $projectList .= "<br>{$row['projectid']}<br>\n"; $projectList .= "<br>{$row['fkey']}<br>\n"; $projectList .= "<br>{$row['paying']}<br>\n"; $projectList .= "<br>{$row['completionmonth']} month {$row['completiondate']} days <br>\n"; $projectList .= "<br>{$row['personspecify']}<br>\n"; $projectList .= "<br>{$row['projecttitle']}<br>\n"; $projectList .= "<br>{$row['categories']}<br>\n"; $projectList .= "<br>{$row['tools']}<br>\n"; $projectList .= "<br>{$row['shortdescription']}<br>\n"; $projectList .= "<br>{$row['date']}<br>\n"; $projectList .= "<br>{$row['time']}<br><br><br><br>\n"; // I want to insert edit button here but dont know how $projectList .= "<form action='edit.php' method='post'>"; $projectList .= "<input type='hidden' name='fkey' value='{$row['fkey']}'>"; $projectList .= "<button type='submit'>Edit</button>"; ec$projectList .=ho "</form><br>\n"; } ?> <html> <head></head> <body> <?php echo $projectList; ?> </body> </html>
  2. Frank, I concur with .josh's original post. I think you are reading something into the post that isn't there. He never stated that you can't implement AJAX without a framework. He was only stating that if you are asking for help with your AJAX implementation be prepared to be asked why you are not using a framework. Why? Because the vast majority of the people asking for help on this forum are novices. These are the people that typically get shunned in other forums because they really don't know what they are doing. These are people that may struggle with creating a simple script to query a database and generate output. AJAX is not rocket science, but it is not something the uninitiated really grasps out of the box. Trying to help someone debug issues with AJAX can be very complicated because of all the different technologies that are typically involved: PHP, MySQL, JavaScript, etc. By using a framework we don't have to read through all of their JavaScript to see if the person wrote wrote the handler correctly or not. It helps to reduce a point of failure that happens all too often. For someone that really knows what they are doing - by all means they can and should write the AJAX code to their specific needs. But, these are also the people that wouldn't need to come and post on a forum for help with it.
  3. Steve started this thread in 2011 and it went unanswered (which I thought was surprising). Markla posted here just recently as he/she was looking for a similar solution. Steve has posted in these forums as late as a couple months ago. But, I would guess he's still not looking for a solution to this. Well, if he is, he is certainly persistent.
  4. Yeah, I'm a terrible person that doesn't want to help people. Of course, that would be overlooking the fact that I did post a solution in this thread earlier and, of course, that would be overlooking the 9,000+ posts I have made in this forum over the years. Whereas, you were given a solution but were too lazy to implement it or try it yourself to see what it would look like.
  5. Yeah, I noticed that. But still, this is a "help" forum, not a "do it for me" forum.
  6. So, you have data and you have the code Barand supplied, yet you want HIM to put it together and provide a screen capture of the results? Why don't you ask him to come over and rub your feet while he's at it.
  7. OK, using the same table structure as the original poster, this appears to work. But, not sure if it is the most efficient. SELECT * FROM (SELECT homeTeam.team_name as home_team, homeGames.all_games_id, home_goals, homeGames.date, homeGames.time FROM teams AS homeTeam LEFT JOIN all_games AS homeGames ON homeTeam.team_id = homeGames.home_team) AS home LEFT JOIN (SELECT awayTeam.team_name as away_team, awayGames.all_games_id, awayGames.away_goals FROM teams AS awayTeam LEFT JOIN all_games AS awayGames ON awayTeam.team_id = awayGames.away_team) AS away ON home.all_games_id = away.all_games_id ORDER BY home_team ASC, away_team ASC
  8. @Barand, The poster was looking for a matrix where every team is listed down the left to represent where they are the home team, and every team is listed across the top to represent where they are the away team. Then the value of each cell is the score of that particular matchup. I don't think your solution really get that - at least not with additional work. I'm trying to solve this, but I'm sure you'll come up with something before me. I'm guessing one option is to have two subqueries. One with all teams listed joing out to the games/results tables and retireve the score for the home team in the matchups. Then do another subquery for every team to get the data where they are away. Then JOIN those two subqueries together based on game_id. At least that's my first thought.
×
×
  • 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.