2 Replies - 477 Views - Last Post: 17 April 2013 - 12:34 AM Rate Topic: -----

#1 aburehan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 16-April 13

redirection error

Posted 16 April 2013 - 10:59 PM

i have a project ....


i want to show products images of different categories , one page is named products.php and other is showproducts.php.
remaining on the products.php page ,when i clicks on a category to see its relevant products it goes to the showproducts.php page , but during this it redirects one time itself to products.php and then quickly it moves automatically to showproducts.php page......

the code of both pages are below

products.php
<?php 
require_once 'newsadmin/library/config.php';
require_once 'newsadmin/library/functions.php';
if(isset($_REQUEST['cat_id']))
{
$sql = "SELECT * FROM tbl_bbcategory WHERE cat_parent_id='$_REQUEST[cat_id]' ORDER BY cat_name";

}
else
{
//$sql = "SELECT * FROM tbl_bbcategory WHERE cat_parent_id='$_REQUEST[cat_id]' ORDER BY cat_name";
$sql = "SELECT cat_id, cat_parent_id, cat_name, cat_description, cat_image FROM tbl_bbcategory WHERE 
cat_parent_id='0' ORDER BY cat_name";
}

$result     = dbQuery($sql);
if (dbNumRows($result) < 1) {

redirect('showproducts.php?cat_id='.$_REQUEST['cat_id']);
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>PAKWOOD Handicraft</title>
<link href="css/global.css" rel="stylesheet" type="text/css" />
<!-- slider -->
<link href="css/js-image-slider.css" rel="stylesheet" type="text/css" />
<script src="js/js-image-slider.js" type="text/javascript"></script>
<link href="generic.css" rel="stylesheet" type="text/css" />
<!-- end slider -->
<link rel="stylesheet" type="text/css" href="css/styles.css" media="all"><style type="text/css">
img, div, .heading,.box-top li { behavior: url(iepngfix.htc) }
</style> 

<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/slider.js"></script>
<script type="text/javascript">	
	jQuery(window).bind('load', function(){
		jQuery().prepare_slider();
		jQuery().intro();		
	});	
	
	

</script><!--[if lte IE 7]>
  	<link rel="stylesheet" href="css/ie.css" type="text/css" media="all">
  <![endif]-->
<!--[if lt IE 9]>
  	<script type="text/javascript" src="js/html5.js"></script>
  <![endif]-->
 <script type="text/javascript" src="highslide/highslide-with-gallery.js"></script>
<link rel="stylesheet" type="text/css" href="highslide/highslide.css" />
<script type="text/javascript"> 
hs.graphicsDir = 'highslide/graphics/';
hs.align = 'center';
hs.transitions = ['expand', 'crossfade'];
hs.outlineType = 'rounded-white';
hs.fadeInOut = true;
hs.numberPosition = 'caption';
hs.dimmingOpacity = 0.75;

// Add the controlbar
if (hs.addSlideshow) hs.addSlideshow({
	//slideshowGroup: 'group1',
	interval: 5000,
	repeat: false,
	useControls: true,
	fixedControls: 'fit',
	overlayOptions: {
		opacity: .75,
		position: 'bottom center',
		hideonmouseout: true
	}
});
</script>
</head>

<body>
<div id="main">
<div id="header">
<div id="logo"><img src="images/logo.jpg"></div><!-- end of logo-->
<div id="rightheader">
<div id="sociallinks">

<a href=""><img src="images/facebook.png"></a>
            			<a href=""><img src="images/twitter.png"></a>
                        <a href=""><img src="images/linkedin.png"></a>
                        <a href=""><img src="images/youtube.png"></a>
													<!-- end of social--></div>
															<!-- end of rightheader--></div>

																	<!-- end of header--></div>

<div id="menu">

         <ul id="items">
            	  <li><a href="index.php"><strong>Home</strong></a></li>
                  <li><a href="about.php"><strong>About us</strong></a></li>
                  <li><a href="products.php"><strong>Products</strong></a></li>
                  <li><a href="quality.php"><strong>Quality Policy</strong></a></li>
                  <li><a href="services.php"><strong>Packing</strong></a></li>
                  <li><a href="certification.php"><strong>Certification</strong></a></li>
                  <li><a href="contacts.php"><strong>Contact Us</strong></a></li>
                  <li><a href="inquiry.php"><strong>Online Order</strong></a></li>
          
        			</ul>
 													<!-- end of menu--> </div>
  
          <div id="slider">

                <img src="slider_images/banner_1.png"  />
            	<img src="slider_images/banner_2.png" />
 				<img src="slider_images/banner_3.png"  />
            	<img src="slider_images/banner_4.png" />
													<!-- end of slider--></div>
<div id="contant">
<div id="blankdiv"><!-- end of blank div--></div>

<div class="heading">PAKWOOD Handicraft Products<!-- end of heading--></div>
<div id="borderdiv"><!-- end of border div--></div>

<div id="leftnav">
		<ul class="block"> 
 <li class="simpleheading">Categories</li>
<li>
	<?php 
 while($row = dbFetchAssoc($result)) {
		extract($row);
		?>

<a href="products.php?cat_id=<?php echo $cat_id; ?>"><?php echo $cat_name; ?></a>


	
	<?php } ?>

	<?php
	$i = 0;
	$PostPerRow = 3;
	?>
    		</li>	
		<!-- end of u-list--></ul>
		
	<!-- end of leftnav--></div>
    	<div id="rightcontant">
		
    <table width="600" border="0" align="center" cellpadding="0" cellspacing="0" >
	<tr><td width="600" height="30" align="left" valign="middle" colspan="5">&nbsp;&nbsp;&nbsp;&nbsp;<a href="index.php">Home </a> >>  <a href="products.php">Products</a> >> <?php echo @$_REQUEST["catname"];?></td>
	</tr>
	<tr>
    <!--  
        
    -->
	<?php
	//////////////
	if(empty($sql))
	{
	$result = dbQuery($sqlcat);
	}
	else
	{	
	$result = dbQuery($sql);
	}
 while($row = dbFetchAssoc($result)) {
		extract($row);
		if ($i % $PostPerRow == 0) {
				echo '<tr height="20px"><td>&nbsp;</td></tr><tr>';
	}
					
			echo "<td align=\"left\">"; 
	
		
		
  ?>
	<a href="products.php?cat_id=<?php echo $cat_id; ?>"><img src="newsadmin/clients/images/category/<?php echo $cat_image; ?>" border="1" style="border-color:#FFFFFF" alt="<?php echo $cat_name; ?>"/></a><br><span class="allcat" style="width:150px"><?php echo $cat_name; ?></span>
	
    <?php
			
		echo "</td>";
		
		if ($i % $PostPerRow == $PostPerRow - 1) {
			echo '</tr>';
							
		}
			 $i += 1;		
		
			
		if ($i % $PostPerRow > 0) {
			echo '<td colspan="' . ($PostPerRow - ($i % $PostPerRow)) . '">&nbsp;</td>';
		}
		
	

?>
	
	
	
	<?php } ?> 

</tr></table>	</div>
	</div><!-- end of content-->
<div id="footer">
       </div>


<div id="footer2">
    	
        
    	  <div class="link">&copy;Copyright All Rights Are Reserved By PAKWOOD Handicraft 2013-14</div>
       	  

<!-- end of main--></div>




</body>
</html>


showproducts.php
<?php 
require_once 'newsadmin/library/config.php';
require_once 'newsadmin/library/functions.php';
if (isset($_GET['cat_id']) && (int)$_GET['cat_id'] > 0) {
	$cat_id = (int)$_GET['cat_id'];
	$queryString = "cat_id=$cat_id";
}

else
{
redirect('showproducts.php?cat_id='.$_REQUEST['cat_id']);
exit;
}
$rowsPerPage = 16;
$sql = "SELECT * FROM tbl_bbproduct WHERE cat_id = '$cat_id'";
$result     = dbQuery(getPagingQuery($sql, $rowsPerPage));
$pagingLink = getPagingLink($sql, $rowsPerPage, $queryString);
$categoryList =buildCategoryOptionsBB($cat_id);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>PAKWOOD Handicraft</title>
<link href="css/global.css" rel="stylesheet" type="text/css" />
<!-- slider -->
<link href="css/js-image-slider.css" rel="stylesheet" type="text/css" />
<script src="js/js-image-slider.js" type="text/javascript"></script>
<link href="generic.css" rel="stylesheet" type="text/css" />
<!-- end slider -->
<link rel="stylesheet" type="text/css" href="css/styles.css" media="all"><style type="text/css">
img, div, .heading,.box-top li { behavior: url(iepngfix.htc) }
</style> 

<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/slider.js"></script>
<script type="text/javascript">	
	jQuery(window).bind('load', function(){
		jQuery().prepare_slider();
		jQuery().intro();		
	});	
	
	

</script><!--[if lte IE 7]>
  	<link rel="stylesheet" href="css/ie.css" type="text/css" media="all">
  <![endif]-->
<!--[if lt IE 9]>
  	<script type="text/javascript" src="js/html5.js"></script>
  <![endif]-->
 <script type="text/javascript" src="highslide/highslide-with-gallery.js"></script>
<link rel="stylesheet" type="text/css" href="highslide/highslide.css" />
<script type="text/javascript"> 
hs.graphicsDir = 'highslide/graphics/';
hs.align = 'center';
hs.transitions = ['expand', 'crossfade'];
hs.outlineType = 'rounded-white';
hs.fadeInOut = true;
hs.numberPosition = 'caption';
hs.dimmingOpacity = 0.75;

// Add the controlbar
if (hs.addSlideshow) hs.addSlideshow({
	//slideshowGroup: 'group1',
	interval: 5000,
	repeat: false,
	useControls: true,
	fixedControls: 'fit',
	overlayOptions: {
		opacity: .75,
		position: 'bottom center',
		hideonmouseout: true
	}
});
</script>
</head>

<body>
<div id="main">
<div id="header">
<div id="logo"><img src="images/logo.jpg"></div><!-- end of logo-->
<div id="rightheader">
<div id="sociallinks">

<a href=""><img src="images/facebook.png"></a>
            			<a href=""><img src="images/twitter.png"></a>
                        <a href=""><img src="images/linkedin.png"></a>
                        <a href=""><img src="images/youtube.png"></a>
													<!-- end of social--></div>
															<!-- end of rightheader--></div>

																	<!-- end of header--></div>

<div id="menu">

         <ul id="items">
            	  <li><a href="index.php"><strong>Home</strong></a></li>
                  <li><a href="about.php"><strong>About us</strong></a></li>
                  <li><a href="products.php"><strong>Products</strong></a></li>
                  <li><a href="quality.php"><strong>Quality Policy</strong></a></li>
                  <li><a href="services.php"><strong>Packing</strong></a></li>
                  <li><a href="certification.php"><strong>Certification</strong></a></li>
                  <li><a href="contacts.php"><strong>Contact Us</strong></a></li>
                  <li><a href="inquiry.php"><strong>Online Order</strong></a></li>
          
        			</ul>
 													<!-- end of menu--> </div>
  
          <div id="slider">

                <img src="slider_images/banner_1.png"  />
            	<img src="slider_images/banner_2.png" />
 				<img src="slider_images/banner_3.png"  />
            	<img src="slider_images/banner_4.png" />
													<!-- end of slider--></div>
<div id="contant">
<div id="blankdiv"><!-- end of blank div--></div>

<div class="heading">PAKWOOD Handicraft Products<!-- end of heading--></div>
<div id="borderdiv"><!-- end of border div--></div>


  <!-- start of code enlarge image -->
<?php /*?><script type="text/javascript">


var dom = (document.getElementById) ? true : false;
var ns5 = (!document.all && dom || window.opera) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ie4 && !ie5 && !dom) ? true : false;

var origWidth, origHeight;

// avoid error of passing event object in older browsers
if (nodyn) { event = "nope" }

///////////////////////  CUSTOMIZE HERE   ////////////////////
// settings for tooltip 
// Do you want tip to move when mouse moves over link?
var tipFollowMouse= true;	
// Be sure to set tipWidth wide enough for widest image
var tipWidth= 455;
var offX= 10;	// how far from mouse to show tip
var offY= 10; 
var tipFontFamily= "Tohama, Verdana, arial, helvetica, sans-serif";
var tipFontSize= "8pt";
// set default text color and background color for tooltip here
// individual tooltips can have their own (set in messages arrays)
// but don't have to
var tipFontColor= "#000000";
var tipBgColor= "#FFFFFF"; 
var tipBorderColor= "#999999";  //F07B1C
var tipBorderWidth= 1;
var tipBorderStyle= "ridge";
var tipPadding= 0;

// tooltip content goes here (image, description, optional bgColor, optional textcolor)
var messages = new Array();
// multi-dimensional arrays containing: 
// image and text for tooltip
// optional: bgColor and color to be sent to tooltip

"<?php
$ServerUrl='newpakwood22/newsadmin/clients/images/product/';
$sql2 = 'SELECT  * FROM tbl_bbproduct WHERE cat_id =' . $cat_id;
$result2 = dbQuery($sql2);

	while($row2 = dbFetchAssoc($result2)) {
	extract($row2);
?>"
messages[<?php echo $pd_id; ?>] = new Array('<?php echo $ServerUrl; ?><?php echo $pd_image; ?>','<?php echo $pd_description; ?>',"#F8F8F6");
"<?php } ?>";




////////////////////  END OF CUSTOMIZATION AREA  ///////////////////

// preload images that are to appear in tooltip
// from arrays above
//if (document.images) {
	//var theImgs = new Array();
	//for (var i=0; i<messages.length; i++) {
  	//theImgs[i] = new Image();
		//theImgs[i].src = messages[i][0];
  //}
//}

// to layout image and text, 2-row table, image centered in top cell
// these go in var tip in doTooltip function
// startStr goes before image, midStr goes between image and text
var startStr = '<table width="' + tipWidth + '"background="images/loader.gif" style="background-repeat:no-repeat; background-position:center"><tr height="50"><td align="center" width="100%"><img src="';
var midStr = '" border="0"></td></tr><tr bgcolor="#E6E7E8"><td align="center" valign="top" style="border-top:1px solid #999999">';
var endStr = '</td></tr></table>';

////////////////////////////////////////////////////////////
//  initTip	- initialization for tooltip.
//		Global variables for tooltip. 
//		Set styles
//		Set up mousemove capture if tipFollowMouse set true.
////////////////////////////////////////////////////////////
var tooltip, tipcss;
function initTip() {
	if (nodyn) return;
	tooltip = (ie4)? document.all['tipDiv']: (ie5||ns5)? document.getElementById('tipDiv'): null;
	tipcss = tooltip.style;
	if (ie4||ie5||ns5) {	// ns4 would lose all this on rewrites
		tipcss.width = tipWidth+"px";
		tipcss.fontFamily = tipFontFamily;
		tipcss.fontSize = tipFontSize;
		tipcss.color = tipFontColor;
		tipcss.backgroundColor = tipBgColor;
		tipcss.borderColor = tipBorderColor;
		tipcss.borderWidth = tipBorderWidth+"px";
		tipcss.padding = tipPadding+"px";
		tipcss.borderStyle = tipBorderStyle;
	}
	if (tooltip&&tipFollowMouse) {
		document.onmousemove = trackMouse;
	}
}

window.onload = initTip;

/////////////////////////////////////////////////
//  doTooltip function
//			Assembles content for tooltip and writes 
//			it to tipDiv
/////////////////////////////////////////////////
var t1,t2;	// for setTimeouts
var tipOn = false;	// check if over tooltip link
function doTooltip(evt,num) {
	if (!tooltip) return;
	if (t1) clearTimeout(t1);	if (t2) clearTimeout(t2);
	tipOn = true;
	// set colors if included in messages array
	if (messages[num][2])	var curBgColor = messages[num][2];
	else curBgColor = tipBgColor;
	if (messages[num][3])	var curFontColor = messages[num][3];
	else curFontColor = tipFontColor;
	if (ie4||ie5||ns5) {
		var tip = startStr + messages[num][0] + midStr + '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';">' + messages[num][1] + '</span>' + endStr;
		tipcss.backgroundColor = curBgColor;
	 	tooltip.innerHTML = tip;
	}
	if (!tipFollowMouse) positionTip(evt);
	else t1=setTimeout("tipcss.visibility='visible'",100);
}

var mouseX, mouseY;
function trackMouse(evt) {
	standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
	mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
	mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
	if (tipOn) positionTip(evt);
}

/////////////////////////////////////////////////////////////
//  positionTip function
//		If tipFollowMouse set false, so trackMouse function
//		not being used, get position of mouseover event.
//		Calculations use mouseover event position, 
//		offset amounts and tooltip width to position
//		tooltip within window.
/////////////////////////////////////////////////////////////
function positionTip(evt) {
	if (!tipFollowMouse) {
		mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
		mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
	}
	// tooltip width and height
	var tpWd = (ie4||ie5)? tooltip.clientWidth: tooltip.offsetWidth;
	var tpHt = (ie4||ie5)? tooltip.clientHeight: tooltip.offsetHeight;
	// document area in view (subtract scrollbar width for ns)
	var winWd = (ns5)? window.innerWidth-20+window.pageXOffset: standardbody.clientWidth+standardbody.scrollLeft;
	var winHt = (ns5)? window.innerHeight-20+window.pageYOffset: standardbody.clientHeight+standardbody.scrollTop;
	// check mouse position against tip and window dimensions
	// and position the tooltip 
	if ((mouseX+offX+tpWd)>winWd) 
		tipcss.left = mouseX-(tpWd+offX)+"px";
	else tipcss.left = mouseX+offX+"px";
	if ((mouseY+offY+tpHt)>winHt) 
		tipcss.top = winHt-(tpHt+offY)+"px";
	else tipcss.top = mouseY+offY+"px";
	if (!tipFollowMouse) t1=setTimeout("tipcss.visibility='visible'",100);
}

function hideTip() {
	if (!tooltip) return;
	t2=setTimeout("tipcss.visibility='hidden'",100);
	tipOn = false;
}

document.write('<div id="tipDiv" style="position:absolute; visibility:hidden; z-index:100"></div>')

</script>



<script language="javascript" type="text/javascript" >
function viewProduct()
{
	with (window.document.frmListProduct) {
		if (cboCategory.selectedIndex == 0) {
			window.location.href = 'products.php';
		} else {
			window.location.href = 'showproducts.php?cat_id=' + cboCategory.options[cboCategory.selectedIndex].value;
		}
	}
}

</script><?php */?>

  <!-- end of code enlarge image -->
  
  
	<br><?php echo @$error; ?></span></td></tr>   
   </table>
  
  
  
 
 </td><td width="80px" class="rightside"></td></tr>
  
  <tr>
    <td width="80px" height="308" class="leftside"></td>
    <td class="innerbg" width="840px" valign="top">
	<table width="792" border="0" cellspacing="0" cellpadding="0" align="center">
	<?php
	$i = 0;
	$PostPerRow = 4;
	?>
	<?php
	$parentId = 0;
if (dbNumRows($result) > 0)
 {
	 while($row = dbFetchAssoc($result)) {
		extract($row);
		if ($i % $PostPerRow == 0) {
				echo '<tr height="20px"><td>&nbsp;</td></tr><tr>';
	}
					
			echo "<td align=\"left\" valign=\"top\">"; 
	
		if ($pd_thumbnail)
		 {
			$pd_thumbnail = WEB_ROOT . 'newsadmin/'.PRODUCT_IMAGE_DIR . $pd_thumbnail;
		} 
		else 
		{
			$pd_thumbnail = WEB_ROOT . 'newsadmin/clients/images/no-image-small.png';
		}
		if ($pd_image)
		 {
			$pd_image = WEB_ROOT . 'newsadmin/'.PRODUCT_IMAGE_DIR . $pd_image;
		} 
		else 
		{
			$pd_image = WEB_ROOT . 'newsadmin/clients/images/no-image-small.png';
		}
		
  ?><span class="allcat" style="width:150px margin-bottom:10px;"><?php echo $pd_name; ?></span><br>
	<a href="<?php echo $pd_image;?>" target="_blank" class="highslide" onclick="return hs.expand(this)">
	
	<?php echo "<img src='$pd_thumbnail' border='0' width='160' height='130' /></a>"
	
	
	
	
	?>
    <?php
			
		echo "</td>";
		
		if ($i % $PostPerRow == $PostPerRow - 1) {
			echo '</tr>';
							
		}
			 $i += 1;		
		
			
		if ($i % $PostPerRow > 0) {
			echo '<td colspan="' . ($PostPerRow - ($i % $PostPerRow)) . '">&nbsp;</td>';
		}
		
	
}
?>
	
	
	
	<?php } ?>
	
</table>
</td>
  <td width="80px" class="rightside"></td>
  </tr>
  <tr>
    <td width="80px"></td>
    <td class="innerbg" width="840px" ><div align="center" class="allcat"><?php 
echo $pagingLink;
   ?></div></td></tr></div></div>
   <div id="footer">
       </div>


<div id="footer2">
    	
        
    	  <div class="link">&copy;Copyright All Rights Are Reserved By PAKWOOD Handicraft 2013-14</div>
       	  

<!-- end of main--></div>
</body>
</html>




thanks

Is This A Good Question/Topic? 0
  • +

Replies To: redirection error

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3730
  • View blog
  • Posts: 6,017
  • Joined: 08-June 10

Re: redirection error

Posted 17 April 2013 - 12:05 AM

Hey.

No offense, but that code is horrible. What you have there is 600+ lines of poorly indented, poorly styled, PHP/HTML/CSS/Javascript/SQL code jumble that will unnecessarily confuse and frustrate even the best programmers.

Here are a few concepts you should look up before continuing your journey into the world of programming. It'll make your code much more understandable. - Programmers tend to spend a lot more of their time reading code than writing it, so readability is key!

- Indentation
- Coding Styles
- Code Separation


As to the question itself. I'm not really following what the problem is. Is it following a link from page A to page B like it's supposed to, but then quickly going back to page A before again going to page B? That's what I got from your description, at least. Could you clarify what the problem actually is?
Was This Post Helpful? 1
  • +
  • -

#3 aburehan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 16-April 13

Re: redirection error

Posted 17 April 2013 - 12:34 AM

actually i don't want to redirect to page A when i want to view the products against the regarding category .would you please remove the redirection link of page A.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1