Welcome! Log In Create A New Profile

Advanced

Fixtures on one page

Posted by lacubagou 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Fixtures on one page
October 01, 2013 03:29PM
Hi Mac, with the players page, you have the option of going to a edit, insert or delete page. The TUT letter however says for fixtures, everything must happen on a the same fixtures.php page.
I just want to confirm, we are then not allowed to create a fixture_edit.php page to edit the fixtures and etc. for add and delete?
avatar
Mac
Re: Fixtures on one page
October 01, 2013 03:45PM
I think this was answered elsewhere.... but yes, same page. if/else statements are very powerful and should be used to maximum effect. Look at it this way - why manage 4 different pages when it could be managed on one page? Remember if the if/else is not true, the rest of the code is not interpreted. Also, by handling a delete query on the same page (if your if/else's are in the correct place) you will not only present the user the result of the delete query, but the listing table will also be immediately available to do a "next" action. If delete is on a separate page, the user needs to navigate back to the listing table - except if you list the table there. That, however, would mean you run the same code on two different pages. And that is a waste.
Re: Fixtures on one page
October 01, 2013 04:10PM
Thanks, for me however, it is a bit more challenging, and messy to use the if/else statements on one page. However I understand your reason.
Apologies for the redundant post, tried looking for this discussion but couldn't find it...
avatar
Mac
Re: Fixtures on one page
October 01, 2013 04:37PM
Not messy at all.... the more pages the more upkeep is required.
avatar Re: Fixtures on one page
October 11, 2013 08:37AM
is it a requirement to use the if/else statements thou,i already completed the project and all functions are working perfectly fine!
Re: Fixtures on one page
October 16, 2013 05:28AM
Where am i going wrong,to what values must i set my $delete,$update?
Language: PHP
<?php session_start();   if (!(!(isset($_SESSION[';login';]) && $_SESSION[';login';] != ';';))) { header("Location: login.php"); }     include("connect.php"); if ($db) { $fixture_id = $_GET[';fixture_id';]; $submit = $_POST[';submit';]; $update = $_GET[';no'; || ';yes';]; $delete = $_GET[';yes'; || ';absolutely';];     $query = "SELECT * FROM fixtures"; $result = mysql_query($query); echo "<table border=';1';><tr bgcolor=';#cccccc';><td>Opponents</td><td>Date</td><td>Venue</td><td>Action</td>"; while($row = mysql_fetch_array($result)) { $fixture_id = $row[';fixture_id';]; $opponents = $row[';fixture_opponents';]; $date = $row[';fixture_date';]; $venue = $row[';fixture_venue';];   echo "<tr><td> $opponents </td><td> $date </td><td> $venue </td><td><a href=fixtures.php?fixture_id=$fixture_id>Update</a></td><td><a href=fixtures.php?fixture_id=$fixture_id>Delete</a></td></tr>"; }     if ($update==';yes';) { echo "<div align=';center'; action=';fixtures.php';>"; echo "<form method=';post';>"; echo "<table cellpadding=';5'; bgcolor=';aqua'; border>"; //table to hold the data in the form aligned echo "<td colspan=';2';>&nbsp&nbsp&nbsp&nbspFixture';s details to be edited:</td></tr>"; echo "<input name=';fixture_id'; type=';hidden'; value=';", $fixture_id, "';>"; echo "<tr>"; echo "<td>Opponents: </td>"; echo "<td><input name=';opponents'; type=';text'; value=';", $opponents, "';></td></tr>"; echo "<br />";   echo "<tr>"; echo "<td>Date: </td>"; echo "<td><input name=';date'; type=';text'; value=';", $date, "';></td></tr>"; echo "<br />";   echo "<tr>"; echo "<td>Venue: </td>"; echo "<td><input name=';venue'; type=';text'; value=';", $venue, "';></td></tr>";   echo "<br />";       echo "<tr >"; echo "<td align=';center'; colspan=';2';><input type=';submit'; value=';update';></td></tr>"; echo "</table>"; echo "</form>"; //end of the form echo "</div>"; } elseif ($delete==';yes';) { echo "Are you sure you want to delete $opponents?<a href=';fixtures.php?delete=absolutely&fixture_id=$fixture_id';>Yes</a>&nbsp;&nbsp;<a href=';fixtures.php';>No</a>"; } elseif ($delete==';absolutely';) { $fixture_id = $_GET[';fixture_id';];//Get the fixture_id from URL $query1 = "DELETE * FROM fixtures WHERE fixture_id = ';$fixture_id';";//Delete a fixture';s details from table based on player_id $result1 = mysql_query($query1); if ($result1) { echo "Fixture deleted successfully."; } else { echo "Failed to delete a fixture <br>"; } } elseif ($submit==';update';) { $fixture_id = $_GET[';fixture_id';];//Get the fixture_id from URL //Update the table $query = "UPDATE fixtures SET fixture_opponents = ';opponents';, fixture_date = ';$date';, fixture_venue = ';$venue'; WHERE fixture_id = ';$fixture_id';"; $result = mysql_query($query); if ($result) { echo "Fixture';s information updated successfully"; } else { echo "Failed to update fixture';s information."; } } else { //link to insert new fixture echo "<a href=insert_fix.php>Insert new fixture</a>"; echo "<br><br>";   $query = "SELECT * FROM fixtures"; $result = mysql_query($query); echo "<table border=';1';><tr bgcolor=';#cccccc';><td>Opponents</td><td>Date</td><td>Venue</td><td>Action</td>"; while($row = mysql_fetch_array($result)) { $fixture_id = $row[';fixture_id';]; $opponents = $row[';fixture_opponents';]; $date = $row[';fixture_date';]; $venue = $row[';fixture_venue';];   echo "<tr><td> $opponents </td><td> $date </td><td> $venue </td><td><a href=fixtures.php?fixture_id=$fixture_id>Update</a></td><td><a href=fixtures.php?fixture_id=$fixture_id>Delete</a></td></tr>"; } }   } mysql_close($connection);
avatar Re: Fixtures on one page
October 16, 2013 08:36AM
Language: PHP
$update = $_GET[';no'; || ';yes';]; $delete = $_GET[';yes'; || ';absolutely';];

$update -

Language: PHP
if (isset($_GET[';fixture_id';]) $update = $_GET[';fixture_id';];


Language: PHP
echo "<tr><td> $opponents </td><td> $date </td><td> $venue </td><td><a href=fixtures.php?fixture_id=$fixture_id>Update</a></td><td><a href=fixtures.php?fixture_id=$fixture_id>Delete</a></td></tr>";
The only place where you mention "Update", you set fixture_id, not any yes or no values.


$delete -

Language: PHP
echo "Are you sure you want to delete $opponents?<a href=';fixtures.php?delete=absolutely&fixture_id=$fixture_id';>Yes</a>&nbsp;&nbsp;<a href=';fixtures.php';>No</a>";

Language: PHP
if (isset($_GET[';delete';]) { $delete = $_GET[';delete';]; $fixture_id = $_GET[';fixture_id';]; }


This part serves no purpose -
Language: PHP
</a>&nbsp;&nbsp;<a href=';fixtures.php';>No</a>";
because you do not set a value for the "delete" variable.
Sorry, only registered users may post in this forum.

Click here to login