Jump to content

keep values after isset() is clicked and refreshed


budimir
Go to solution Solved by budimir,

Recommended Posts

Guys,

 

How could I keep values when isset() is clicked and after that a link is clicked which does something. I have paging inside if (isset(submit)) and when clicked next on paging everything goes back to previous state it doesn't keep values for filtering.

 

Below is code, I'm using. Please, help...

Form

		<form method="GET" action="<?php echo $_SERVER['PHP_SELF']; ?>">
		<input type="hidden" name="id" value="<?php echo "$id_kalkulacije"; ?>">
		   Upišite podgrupu proizvoda: <input type="text" name="podgrupa_proz">
		   <input type="submit" name="submit1" value="Traži">
		</form>

Php code

else if (isset($_GET["submit1"])) {

//pretraživanje po kategoriji
$id_kalkulacije = $_GET["id"];
$podgrupa_proz = $_GET["podgrupa_proz"];
$_SESSION["podgrupa_proz"] = $podgrupa_proz;

//Početak paginga
		if (isset($_GET['pageno'])) {
   			$pageno = $_GET['pageno'];
		} else {
   			$pageno = 1;
		} // if
		
		$upit11 = mysql_query("SELECT id FROM kalkulacija_stavke WHERE id_kalkulacija = '$id_kalkulacije' AND podgrupa_proizvoda LIKE '%".$_SESSION["podgrupa_proz"]."%'") or die (mysql_error());
		$brojcanik = mysql_num_rows($upit11);
		$rows_per_page = 100;
		$lastpage = ceil($brojcanik/$rows_per_page);
		$pageno = (int)$pageno;

		if ($pageno > $lastpage) {
		   $pageno = $lastpage;
		} // if
		
		if ($pageno < 1) {
		   $pageno = 1;
		} // if
		
		$limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page;


SOME QUERY WITH RESULT DISPLAY HERE......


	if ($pageno == 1) {
   		echo " <font color='#990000'>Početak</font> || Natrag ";
	} else {
   		echo " <a href='{$_SERVER['PHP_SELF']}?pageno=1&id=$id_kalkulacije&podgrupa_proz=$podgrupa_proz'>Prva</a> | ";
	    $prevpage = $pageno-1;
	    echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage&id=$id_kalkulacije&podgrupa_proz=$podgrupa_proz'>Natrag</a> ";
	} // if
	
		echo " ( <font color='grey'>Stranica - <b>$pageno</b> od <b>$lastpage</b></font> ) ";

	if ($pageno == $lastpage) {
   		echo " Naprijed || <font color='#990000'>Kraj</font> ";
	} else {
	   $nextpage = $pageno+1;
   	   echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage&id=$id_kalkulacije&podgrupa_proz=$podgrupa_proz'>Naprijed</a> | ";
       echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$lastpage&id=$id_kalkulacije&podgrupa_proz=$podgrupa_proz'>Posljednja</a> ";
	} // if
       echo " <br />Rezultata: ".$brojcanik." </p>";

 

Link to comment
Share on other sites

  • Solution

I did store it in Session, but it doesn't work for some reason which I can't figure out. I do a session_start() in one of the include files I'm using, if you thought I didn't start the session.

 

Is it a problem with if (isset(submit)) that's not set when I click a link for next page on paging part??? If that is the problem how can I go around it?

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.