I'm doing a fix on some existing code and have a feeling this is an easy fix but would appreciate any guidance.
A page holds rows of 6 images each - 20 rows per page often with result sets of 20+. These rows have set fields where the user can annotate notes on the row, radio buttons etc. The rows are also divided up by user defined categories which can be sorted by drop down menu at the top of the page - with the default being "View Everything". And if a user makes changes or annotates a row, there is a, Update Page submit button at the bottom of the page.
The issue is if the user has sorted through the drop down to narrow his result set and is let's say 3 pages deep into that set - and he then "Updates Page" on an individual record, the code takes him back to the default View Everything - thereby nullifying his current search.
Is their anyway to override this default - and have the Update keep the user where he is in the search. I know there is a simple answer to this ... any help would be appreciated ...
Here is the code to the file
**** CODE REMOVED BECAUSE I POSTED IT WITH SPACES AND WITHOUT COLOR TAGS - PLEASE SEE BELOW ***
Update nullifies current search, navigation, easeofuse issue
Moderator: General Moderators
-
shotdsherrif
- Forum Newbie
- Posts: 3
- Joined: Sun Mar 15, 2009 2:37 pm
Update nullifies current search, navigation, easeofuse issue
Last edited by shotdsherrif on Wed Mar 18, 2009 12:54 am, edited 1 time in total.
-
shotdsherrif
- Forum Newbie
- Posts: 3
- Joined: Sun Mar 15, 2009 2:37 pm
Re: Update nullifies current search, navigation, easeofuse issue
I'm new to the forum and realized I asked a question without reading the general guidelines first ... so sorry about that ... here is another stab at trying to figure out what my problem is. The problem is described above in the first post but I'm going to repost the code to make it easier to read
my basic issue remains figuring out why the "Update this page" Submit defaults the user to the - select * from project - when they might be pages deep into a specific - talent where $user and shot - result set ...
I'm trying to make it so the update keeps the user where they are in the search - by both page and scroll. I don't yet have a good handle on Session logic and have a feeling that might be the problem.
This is inherited code and I know the fix is probably simple since I've already fixed a similar javascript based toplink default in this same page.
at any rate, I'm really trying here and would appreciate any guidance ... even if just advice on how to better articulate my question. Thx in advance.
my basic issue remains figuring out why the "Update this page" Submit defaults the user to the - select * from project - when they might be pages deep into a specific - talent where $user and shot - result set ...
I'm trying to make it so the update keeps the user where they are in the search - by both page and scroll. I don't yet have a good handle on Session logic and have a feeling that might be the problem.
This is inherited code and I know the fix is probably simple since I've already fixed a similar javascript based toplink default in this same page.
at any rate, I'm really trying here and would appreciate any guidance ... even if just advice on how to better articulate my question. Thx in advance.
Code: Select all
<?php
session_start();
include("body.php");
include("dbconnect.php");
include("breaknumber.php");
include "includes/function.php";
$user = $_SESSION[user];
$p_name = $_REQUEST['p_name'];
$q_str = "&p_name=$p_name";
if ($_POST['submit'] == "go")
{
if ($_REQUEST['a'] == "l")
{
Redirectn("proj_locations.php?p_name=$p_name");
exit;
}
elseif ($_REQUEST['a'] == "p")
{
Redirectn("proj_props.php?p_name=$p_name");
exit;
}
elseif ($_REQUEST['a'] == "s")
{
Redirectn("proj_sets.php?p_name=$p_name");
exit;
}
elseif ($_REQUEST['a'] == "t")
{
Redirectn("proj_talents.php?p_name=$p_name");
exit;
}
elseif ($_REQUEST['a'] == "d")
{
$pid = $_REQUEST['pid'];
Redirectn("documents.php?p_name=$p_name&pid=$pid&pro=ch");
exit;
}
}
$qry = mysql_query("select * from projects where p_owner = '$user'");
$row_dir = mysql_fetch_array($qry);
$directory = $row_dir['p_name'];
$did = $row_dir['id'];
$where = "memberUsername = '$user'";
$select = select_single_record("members","*","$where");
$memberBrand = $select[1]['memberBrand'];
$memberWebsite = $select[1]['memberWebsite'];
$memberCompany = $select[1]['memberCompany'];
if ($_POST["submit"] == "Update This Page")
{
$talent_id = $_POST['talent_id'];
for($li=0;$li<sizeof($talent_id);$li++)
{
$lid = $talent_id[$li];
$execution = addslashes($_POST["execution$lid"]);
$user_notes = addslashes($_POST["user_notes$lid"]);
$approve = addslashes($_POST["approve$lid"]);
$photog = addslashes($_POST["photog$lid"]);
$producer = addslashes($_POST["producer$lid"]);
$agency = addslashes($_POST["agency$lid"]);
$appv = addslashes($_POST["appv$lid"]);
if ($photog != 1){
$photog = 0;
}
if ($producer != 1){
$producer = 0;
}
if ($agency != 1){
$agency = 0;
}
if ($appv != 1){
$appv = 0;
}
$up_qry = mysql_query("update talent set execution = '$execution', user_notes = '$user_notes', approved = '$approve', photog = '$photog', producer = '$producer', agency = '$agency', appv ='$appv' where who = '$user' and id = '$lid'");
}
}
//$today = date("n/j/Y");
$show = $_REQUEST['show'];
if ($show == "hero")
{
$qry = "select pl.shot as proj, pl.id as pid, orig_id, pdate, pl.execution, pl.user_notes, h.imageid as imageid, h.frame as frame from talent as pl, heros as h where pl.id = h.id and pl.who = '$user' and pl.shot = '$p_name' and h.type = 'TALENT'";
$qry .= " order by pl.execution";
}
else
{
$qry = "select * from talent where who = '$user' and shot = '$p_name'";
if ($_POST['a'] == "asearch")
{
$org_id = $_POST['org_id'];
$qry .= " and (concat_ws(' ',fname,lname) LIKE '%$org_id%' or fname LIKE '%$org_id%' or lname LIKE '%$org_id%')";
}
$show = $_REQUEST['show'];
if ($show != ""){
$q_str .= "&show=$show";
switch ($show)
{
case latest:
$qry_up = mysql_query("select * from talent where who = '$user' and shot = '$p_name' ORDER BY `lpdate` DESC limit 0,1");
$up_row = mysql_fetch_array($qry_up);
$today = $up_row['lpdate'];
$qry .= " and lpdate = '$today'";
//$qry .= " and pdate = '$today'";
break;
case photog:
$qry .= " and photog = 1";
break;
case producer:
$qry .= " and producer = 1";
break;
case agency:
$qry .= " and agency = 1";
break;
case appv:
$qry .= " and appv = 1";
break;
default:
$q_str .= "&show=$show";
$qry .= " and execution = '$show'";
break;
}
}
$qry .= " order by execution, orig_id desc";
}
$count = mysql_query($qry);
if(!$count) die(mysql_error());
$err = mysql_num_rows($count);
if(!$count) die(mysql_error());
$total = mysql_num_rows($count);
$page = $_REQUEST['page'];
if((!$page) || (is_numeric($page) == false) || ($page < 0) || ($page > $total)) {
$page = 1; //default
}
//For Paging
$limit = 20;
$pager = getPagerData($total, $limit, $page);
$offset = $pager->offset;
$limit = $pager->limit;
$page = $pager->page;
$set_qry = $qry." LIMIT $offset, $limit";
$q = mysql_query($set_qry);
$doc_qry = mysql_query("select * from projects where r_id = '$did' and p_name = '$p_name'");
$doc_row = mysql_fetch_array($doc_qry);
$exeid = $doc_row['id'];
$sql_doc = mysql_query("select DISTINCT type from documents where exe = '$exeid' and owner = '$user'");
$sql_l = mysql_query("select * from proj_loc where who = '$user' and shot = '$p_name'");
$sql_p = mysql_query("select * from proj_props where who = '$user' and shot = '$p_name'");
$sql_s = mysql_query("select * from proj_sets where who = '$user' and shot = '$p_name'");
$sql_t = mysql_query("select * from talent where who = '$user' and shot = '$p_name'");
?>
-
shotdsherrif
- Forum Newbie
- Posts: 3
- Joined: Sun Mar 15, 2009 2:37 pm
Re: Update nullifies current search, navigation, easeofuse issue
Also, someone in another forum suggested I use the parse_url function to ensure the current query string is appended to the url specified in the form action ... not sure if that is the right path to take or not ... I've taken on this relatively small job in order to begin wrapping my mind around the logic of php ... I already have a basic grasp of common syntax ...
so in other words ... I'm as interested in understanding why the code is behaving the way it is as i am in resolving the issue ...
so in other words ... I'm as interested in understanding why the code is behaving the way it is as i am in resolving the issue ...