1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP: Help needed in PHP MYSQLwith dynamic urls

Discussion in 'PHP' started by Madhu_byke, Dec 4, 2010.

  1. Madhu_byke

    Madhu_byke New Member

    Joined:
    Dec 4, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    My problem is in this below code to find the SubcategoryName that was clicked so that products.php is loaded based on SubcategoryName condition.

    $result1 = mysql_query("SELECT * FROM subcategory WHERE idCate = $mad ");
    $result2 = mysql_num_fields($result);
    while($row = mysql_fetch_array($result1))
    {
    echo "<tr>";
    echo "<td>" . '<a href="products.php">' . $row['SubcategoryName'] . '</a>' . "</td>";
     
  2. Madhu_byke

    Madhu_byke New Member

    Joined:
    Dec 4, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    <?php
    		require("connect.php");
    			$result = mysql_query("SELECT * FROM category ORDER BY idcategory");
    			while($row1 = mysql_fetch_array($result))
    			  {
    			  echo "<tr>";
    			  echo "<th>" . $row1['CategoryName'] . "</th>";
      			  echo "</tr>";
    			  $mad = $row1['idcategory'];
    			  $result1 = mysql_query("SELECT * FROM subcategory WHERE idCate =  $mad ");
    			  $result2 = mysql_num_fields($result);
    				while($row = mysql_fetch_array($result1))
    				  	  {
    						echo "<tr>";
                             //                     I actually need the value of the SubcategoryName that is clicked.
    						echo "<td>" . '<a href="products.php">' . $row['SubcategoryName'] . '</a>' . "</td>";
                            //                      so that products.php is loaded based on the SubcategoryName that is clicked
    			//			echo $row['SubcategoryName'];
    						echo "</tr>";
    					  };
    					  echo "<br />";
    			  }
    		mysql_close($con);
    	?>
     
    Last edited by a moderator: Dec 4, 2010

Share This Page