Jump to content

This is Weird !


vanvoquan

Recommended Posts

I have test this code in a simple php file, it works perfect. But when i try to put it in another file it doesn't work. I spent days to find out why but no success, Can anyone help me with this please. Thanks million times. Below is the form:

<a href="http://localhost/thu3/page3.php" onclick="document.myform.submit(); return false">Click 1st</a><br>
<form action="http://localhost/thu3/page3.php" method="post" name="myform">
<input type="hidden" name="categories" value="Bumper">
</form>

And i try to put it in this file:

 </tr>
<!-- BOF: Show subcategories in Product Listing -->
    <tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="2"><tr><?php
echo "<form method=\"post\" name=\"myform\" action=\"http://localhost/thu3/page3.php\">";
echo "<input type=\"hidden\" name=\"categories\" value=\"bumper\">";
echo "</form>";
        if (isset($cPath)) {
		if (ereg('_', $cPath)) {
			$category_links = array_reverse($cPath_array);
			$cat_to_search = $category_links[0];
			}
		else {
			$cat_to_search = $cPath;
			}
	    // check to see if there are deeper categories within the current category		  	
	  	$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, 

c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . $cat_to_search 

. "' and c.categories_id = cd.categories_id and cd.language_id = '" . $languages_id . "' order by sort_order, 

cd.categories_name");
		    if (tep_db_num_rows($categories_query) > 0 ) {
			    $rows = 0;
				while ($categories = tep_db_fetch_array($categories_query)) {
				    $rows++;
					$cPath_new = tep_get_path($categories['categories_id']);
					$width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';
					echo '                <td align="center" class="smallText" style="width: ' . 

$width . '" valign="top"><a href="http://localhost/thu3/page3.php" onclick="document.myform.submit(); return false">' . tep_image(DIR_WS_IMAGES . 

$categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br>' 

. $categories['categories_name'] . '</a></td>' . "\n";
					if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / 

MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != tep_db_num_rows($categories_query))) {
						echo '              </tr>' . "\n";
						echo '              <tr>' . "\n";
						}
				}
			}
	}						
    ?></tr></table></td>
</tr>
<tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
    </tr>
<!-- EOF: Show subcategories in Product Listing -->
      <tr>
        <td><?php include(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING); ?></td>
      </tr>
    </table>
</td>

<?php
  }
?>

Link to comment
https://forums.phpfreaks.com/topic/112505-this-is-weird/
Share on other sites

Why are you using Javascript to pass this value? You could use a SESSION variable.

 

At the start of the scripts where you want to use the value put

<?php
session_start();
?>

 

When you want to store the variable, use

<?php
$_SESSION['categories'] = "bumper";
?>

 

When you want to use it:

<?php
$catagories = $_SESSION['categories'];
?>

 

Ken

Link to comment
https://forums.phpfreaks.com/topic/112505-this-is-weird/#findComment-577716
Share on other sites

Thanks all for helping. Firs of all I try using session but It didn't work because i have so many variables, like bumper, hood, light, fender... I can't create the session for every single one of them. Second of of all the $_POST['categories'] from vicodin is working, thanks alot. But I run into a problem. The value only carry on to the next page IF the destination of the form action and the a href is the same. Can anyone please help me make this value :

[<a href="' . tep_href_link(FILENAME_MAKES, $cPath_new) . '" onclick="document.myform.submit(); return false">/code] and the form action go to this destination : [code]' . tep_href_link(FILENAME_MAKES, $cPath_new) . '

. I try to put the  ('tep_href_link(FILENAME_MAKES, $cPath_new) . ' in the form action="' . tep_href_link(FILENAME_MAKES, $cPath_new) . '" but it doesn't work.

Thanks in advance

Vanvoquan

[/code]

Link to comment
https://forums.phpfreaks.com/topic/112505-this-is-weird/#findComment-577755
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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