View Full Version : Editing Information

10-31-2009, 09:43 PM
I don't know what I'm doing wrong. What I want to happen is when I want to edit the name of a division I click on edit next to the division name and it takes me to the editdivision function where it should go to the DB and grab the name but it isn't. I'm not sure what I'm doing wrong?

function divisions() {
print '<h1 class="backstage">Division Management</h1><br />';
print "<h2 class=backstage>Divisions :: <a href=\"#\" onclick=\"ajaxpage('adddivision', 'content'); return false;\">Add New</a></h2><br />";
$query = "SELECT * FROM divisions ORDER BY `division`";
$result = mysql_query ( $query ); // Run The Query
$rows = mysql_num_rows($result);
if ($rows > 0)
print '<table width="100%" class="table1">';
print '<tr class="rowheading">';
print '<td>&nbsp;</td>';
print '<td>Name</td>';
print '</tr>';
// Fetch and print all records.
$i = 0;
$current_row = 0;
while ( $row = mysql_fetch_array ( $result, MYSQL_ASSOC ) )
$sClass = 'row2';
if ($i ++ & 1)
$sClass = 'row1';
printf ( "<tr class=\"%s\">", $sClass );
print "<td valign=\"top\" align=\"center\" width=\"30\"><a href=\"#\" onclick=\"ajaxpage('editdivision', 'content', '".$row['division']."'); return false;\">Edit</a></td>";
printf ( "<td valign=\"top\">%s</td>", $row [division] );
print '</tr>';
echo '</table>';
print '<span>There are no divisions.</span><br />';
print '<br />';

function editdivision()
$division = $_GET['division'];
$query = mysql_query("SELECT * FROM `divisions` WHERE `division` = '" . $division . "'");
$row = mysql_fetch_array($query);
print '<h1 class="backstage">Division Management</h1><br />';
print '<h2 class="backstage">Edit Division</h2><br />';
print '<form name="editmatchtype" method="post" action="backstage.php" id="editmatchtype">';
print '<table width="100%" class="table2">';
print '<tr>';
print "<td width=\"120\" class=\"rowheading\" valign=\"center\">Division:</td><td class=\"row3\"><input type=\"text\" name=\"division\" class=\"fieldtext490\" value=\"".$row['division']."\"></td>";
print '</tr>';
print '</table><br />';
print '<center>';
print '<input type="checkbox" name="deletedivision"><span class="table1heading">Delete Division?</span><br /><br />';
print '<input type="hidden" name="division" value="'.$division.'">';
print '<input type="hidden" name="olddivision" value="'.$row['division'].'">';
print '<input type="submit" value="Edit Division" class=button name="editdivision"><br /><br />';
print '<input type="button" value="Return to Divisions List" class="button200"><br /><br />';

10-31-2009, 10:29 PM
can't see what the onclick(ajaxpage) is doing, but the only thing I can see is that you aren't setting the <a> (so nothing is being entered in to the $_GET array)

unless thats what the onclick is doing, can't really tell.

my code below will make the link "page.php#?division=division"

which should then work with your function.

also check the source to see if the hidden field is being set.

print "<td valign=\"top\" align=\"center\" width=\"30\"><a href=\"#?division=".$row['division']."\" onclick=\"ajaxpage('editdivision', 'content', '".$row['division']."'); return false;\">Edit</a></td>";