Jump to content

Losing 'page' data


paradoxmime

Recommended Posts

I have this code that allows me to update my database. But after updating, I lose the $_GET['page'] value in the browser. I need this value because it is passed when I go to other pages on the site.

 

echo ($_GET['change'] == 'Garage_Type') ?
            '<form method="get" action="' . $_SERVER['PHP_SELF'] .
            '">
    <select name="Garage_Type">
    <option value="Attached">Garage </option>
	<option value="Detached">Detached Garage </option>
    <option value="Attached Carport">Carport </option>
	<option value="Detached Carport">Detached Carport </option>
	<option value="None">None </option>   
    </select>
    
    <input type="submit" name="submit" value="Update DB!" /><input type="hidden" name="id" value="' . $this->_ID . '" /><input type="hidden" name="col" value="Garage_Type" /></form>' . '</td></tr></table></td></tr><tr><td colspan="3" bgcolor="#CCCCCC"></td></tr><tr><td>':
            $this->_DATA['Garage_Type'] . '</td></tr></table> </td><td><a href="' . $_SERVER['PHP_SELF'] . '?change=Garage_Type&id=' .$this->_ID .'&page='.$_GET['page'].'&orderid='.$_GET['orderid'].'&asc='.$_GET['asc'].'">Edit</a>' .
            '</td></tr><tr><td colspan="3" bgcolor="#CCCCCC">';

 

Link to comment
Share on other sites

In my file upload fields, it doesn't lose the page value. Here is the code for it:

 

 echo ($_GET['upload'] == 'Review_PDF') ?
            '<form method="post" enctype="multipart/form-data" action="' . $_SERVER['PHP_SELF'] . '?id=' . $this->_ID .'&page='.$_GET['page'].'&orderid='.$_GET['orderid'].'&asc='.$_GET['asc'].'">
            <input name="Review_PDF" type="file" id="Review_PDF">
<input type="hidden" name="col" value="Review_PDF" /><input type="hidden" name="id" value="' . $this->_ID . '" /><input type="submit" value="Insert!" name="comsubmit" /></form></td></tr><tr><td>' :
'<table width="200" align="left"><tr><td>NONE</td></tr></table></td><td><a href="' . $_SERVER['PHP_SELF'] . '?upload=Review_PDF&id=' . $this->_ID .'&page='.$_GET['page'].'&orderid='.$_GET['orderid'].'&asc='.$_GET['asc'].'">Insert Record to DB</a>' . 
            '</td></tr><tr><td colspan="3" bgcolor="#000000" height="1"></td></tr><tr><td>';

Link to comment
Share on other sites

Update your form action:

 

echo ($_GET['change'] == 'Garage_Type') ?
            '<form method="get" action="' . $_SERVER['PHP_SELF'] .
            '?page=' . $_GET['page'] . '">

 

You can see that the second form you posted passes the page in action="" along with some other variables.

Link to comment
Share on other sites

post your query.  the error you're receiving is from an error in your mysql query.

 

and you say you lose it after updating.

 

to keep use of 'page', you must continue to pass 'page' from page to page.  perhaps if i see your query i will have a better understanding what you are doing (or not doing).

Link to comment
Share on other sites

mysql_select_db('TGC');
if($_GET["asc"]==1)
$ord="asc";
else
$ord="desc";
        /* For ordering by */
        switch($_GET['orderid']) {
       case 1:
            $orderby = "Public $ord";
            break;
   case 2:
            $orderby = "Plan_Number $ord";
            break;
        case 3:
            $orderby = "Sq_Feet $ord";
            break;
        case 4:
            $orderby = "Date_Added $ord";
            break;
        case 5:
            $orderby = "Date_Modded $ord";
            break;
	case 6:
            $orderby = "Rating $ord";
            break;
	case 7:
            $orderby = "Sales_PDF $ord";
            break;
        default:
            $orderby = "Plan_Number asc";
        }

        $SQL = "SELECT Plan_ID, Public, Plan_Number, Sq_Feet, Elevation, Date_Added, Date_Modded, Sales_PDF, Garage_Location, User_Rating,Sold FROM House_Plans WHERE Des_ID = '$this->_ID' and Deleted<>1 ORDER BY $orderby";
if(!isset($_GET["page"])){ 
    $page = 1; 
} else { 
    $page = $_GET["page"];
} 

// Define the number of results per page 
$max_results = 10; 

// Figure out the limit for the query based 
// on the current page number. 
$from = (($page * $max_results) - $max_results); 

// Perform MySQL query on only the current page number's results 

$result = mysql_query($SQL." LIMIT $from, $max_results");

// Figure out the total number of results in DB: 
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM House_Plans WHERE Des_ID = '". $this->_ID ."'"),0); 


//code to find online and offline plans
     $sql_number="SELECT Public FROM House_Plans WHERE Des_ID = '". $this->_ID ."'";
 $sql_query=mysql_query($sql_number);
 while($sql_res=mysql_fetch_array($sql_query))
   {
     if($sql_res["Public"]==1)
	    $m++;
	 else
	    $k++;
   }

Link to comment
Share on other sites

The page has a lot of code so I will tell you which lines to look at... Look at the very bottom. Notice the "Begin Review" area? This is a file upload form that works fine. All the file uploads work. When I say 'works', I mean that after entering data or uploading afile, I am still able to click the "back to user panel" link where it takes me back to the userpanel and everything displays correctly. That is because the"page=" passes a value that userpanel can use to determine what to show.

Then scroll up til you see

 if (!empty($this->_DATA['Plan_Description']))

This form and all the others above it do not pass the page= value. Now I know that currently it shows

'<form method="get" action="' . $_SERVER['PHP_SELF'] .
      '">

and does not include the

'?id=' . $this->_ID .'&GP_upload=1&page='.$_GET['page'].'&orderid='.$_GET['orderid'].'&asc='.$_GET['asc'].

I have tried this and it still does not work. I am missing something somewhere

 

[attachment deleted by admin]

Link to comment
Share on other sites

I'm sorry but I can't help.  I think what you're missing is a bit of organisation, that file is a mess - sorry but there's no other word for it.  It's no doubt a bit late to go back and re-think the structuring of the page but sometimes it's needed.

 

If you've added the necessary get variables to the form action and it isn't working, then I think that's as far as I can help you anyway.  It would take too long for me to understand how your code flows, only you know that.

 

The only thing I can suggest is this: add the necessary ?id & page= etc to the form action, load the page (but don't submit).  Check the source code (right-click view source) and see whether the form action has the correct values in it.

Link to comment
Share on other sites

I can see how things may seem confusing. I have deleted everything that doesn't matter or apply to the situation. I left anything that might be needed. Don't pay any attention to the <td><tr> tags that might be missing. I have attached the file. Please look again and see if it's easier for you this time.

 

[attachment deleted by admin]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.