PDA

View Full Version : How do I fix this problem?


vietfancy
13 Dec 2009, 23:19
This code below seems to work just fine except for when edit and update it just go back to 1 page.

ex: when I view do=sat after edit and update a class ... it redirect back to do=fri. How do I keep it stay in do=sat?

I know the code tell it to go back to do=fri is: print_cp_message('Class has been updated', 'schedule.php?do=' . iif($type==1,'fri'));
but how do I fix it?

Thanks.

here is the code.


if($_REQUEST['do'] == 'fri'){
print_form_header('schedule', 'delete', false, true, 'delete', '90%', '', true, 'post', 0);
print_table_header("Friday Classes",6);

$items = $db->query_read("
SELECT *
FROM " . TABLE_PREFIX . "table
WHERE day = 'friday' AND live = '1'
ORDER BY time
");
$i = 1;
if($db->num_rows($items))
while($item = $db->fetch_array($items))
{
if($i%2==0) $class = 'alt2'; else $class = 'alt1';
echo '<tr class="' . $class . '">
<td align="center" class="smallfont">'. htmlspecialchars($item['class']) .' <a href="schedule.php?do=edit&scheduleid=' . $item['id'] . '&type=1" title="Edit"><img title="Edit Class" alt="Edit Class" src="../images/misc/userfield_edit.gif" border="0" hspace="6"></a></td>
</tr>';
$i++;
}
else echo '<tr class="alt1"><td align="center" colspan="6">No Class Found!</td></tr>';
$db->free_result($items);
print_submit_row('Delete" onclick="return confirm(\'Are you sure you want to delete?\')', 'Reset', 6, '', '', false);
print_cp_footer();
}
//Sat
if($_REQUEST['do'] == 'sat'){
print_form_header('schedule', 'delete', false, true, 'delete', '90%', '', true, 'post', 0);
print_table_header("Saturday Classes",6);

$items = $db->query_read("
SELECT *
FROM " . TABLE_PREFIX . "table
WHERE day = 'saturday' AND live = '1'
ORDER BY time
");
$i = 1;
if($db->num_rows($items))
while($item = $db->fetch_array($items))
{
if($i%2==0) $class = 'alt2'; else $class = 'alt1';
echo '<tr class="' . $class . '">
<td align="center" class="smallfont">'. htmlspecialchars($item['class']) .' <a href="ese_schedule.php?do=edit&scheduleid=' . $item['id'] . '&type=1" title="Edit"><img title="Edit Class" alt="Edit Class" src="edit.gif" border="0" hspace="6"></a></td>
</tr>';
$i++;
}
else echo '<tr class="alt1"><td align="center" colspan="6">No Class Found!</td></tr>';
$db->free_result($items);
print_submit_row('Delete" onclick="return confirm(\'Are you sure you want to delete?\')', 'Reset', 6, '', '', false);
print_cp_footer();
}

if($_REQUEST['do']=='edit'){
$scheduleid = $vbulletin->input->clean_gpc('r','scheduleid',TYPE_INT);
$type = $vbulletin->input->clean_gpc('r','type',TYPE_INT);
$item = $db->query_first("
SELECT *
FROM " . TABLE_PREFIX . "table
WHERE id = $scheduleid
");
print_form_header('schedule', 'update');
construct_hidden_code('scheduleid', $scheduleid);
construct_hidden_code('type', $type);
print_hidden_fields();
print_table_header('Editing Class');
print_input_row('Class:', 'class', $item['class']);
print_submit_row('Save');
print_cp_footer();
}
if($_REQUEST['do']=='update'){
$scheduleid = $vbulletin->input->clean_gpc('p','scheduleid',TYPE_INT);
$class = $vbulletin->input->clean_gpc('p','class',TYPE_STR);
$type = $vbulletin->input->clean_gpc('p','type',TYPE_INT);
$extra = "";
$item = $db->query_write("
UPDATE " . TABLE_PREFIX . "table
SET class = '" . $db->escape_string($class) . "'$extra
WHERE id = $scheduleid
");
print_cp_message('Class has been updated', 'schedule.php?do=' . iif($type==1,'fri'));
}