vanvoquan Posted June 29, 2008 Share Posted June 29, 2008 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 More sharing options...
kenrbnsn Posted June 30, 2008 Share Posted June 30, 2008 What do you mean by "it doesn't work"? Do you get errors? Ken Link to comment https://forums.phpfreaks.com/topic/112505-this-is-weird/#findComment-577672 Share on other sites More sharing options...
vanvoquan Posted June 30, 2008 Author Share Posted June 30, 2008 I didn't get any errors but I don't get the value from the form ( value=\"bumper\"). I Link to comment https://forums.phpfreaks.com/topic/112505-this-is-weird/#findComment-577701 Share on other sites More sharing options...
vicodin Posted June 30, 2008 Share Posted June 30, 2008 Well no where in that code do i see a $_POST['categories'] so its not going to transfer that input box over to the next page. Link to comment https://forums.phpfreaks.com/topic/112505-this-is-weird/#findComment-577707 Share on other sites More sharing options...
kenrbnsn Posted June 30, 2008 Share Posted June 30, 2008 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 More sharing options...
vanvoquan Posted June 30, 2008 Author Share Posted June 30, 2008 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 More sharing options...
vanvoquan Posted June 30, 2008 Author Share Posted June 30, 2008 Can somebody pleaseeeeee help Link to comment https://forums.phpfreaks.com/topic/112505-this-is-weird/#findComment-577801 Share on other sites More sharing options...
kenrbnsn Posted June 30, 2008 Share Posted June 30, 2008 Stop whining. If someone knows how to solve your problem they will post. Ken Link to comment https://forums.phpfreaks.com/topic/112505-this-is-weird/#findComment-577803 Share on other sites More sharing options...
MasterACE14 Posted June 30, 2008 Share Posted June 30, 2008 use an array in a session variable for the whole lot. Link to comment https://forums.phpfreaks.com/topic/112505-this-is-weird/#findComment-577880 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.