mardi 17 septembre 2019

I want to display data on same page when user click on link

I am working on a site. i have a navbar which is dynamic. i want to display the data on same page when user click on link. i am using $_REQUEST. Code is working fine but when i run the script it gives an error that 'undefined index val'... but when user click on a link it works fine. i want to remove that error.please guide me

<html>
<head>
<style>
body {
    background: #212121;
    font-size:22px;
    line-height: 32px;
    color: #ffffff;
    word-wrap:break-word !important;
    font-family: 'Quicksand', sans-serif;
    margin: 0;
    padding: 0;
}
h1 {
    font-size: 60px;
    text-align: center;
    color: #FFF;
    margin-top: 150px;
    font-family: 'Russo One', sans-serif;
    }
h1 span {
    color: #FF4649;
}
#container {
    margin: 0 auto;
}

nav {
    margin: 35px 0;
    background-color: #FF4649;
}
nav ul {
    padding: 0;
        margin: 0;
    list-style: none;
    position: relative;
    }    
nav ul li {
    display:inline-block;
    background-color: #FF4649;
    }
nav a {
    display:block;
    padding:0 10px;    
    color:#FFF;
    font-size:20px;
    line-height: 60px;
    text-decoration:none;
}
nav a:hover { 
    background-color: #333; 
}
nav ul ul {
    display: none;
    position: absolute; 
    top: 60px;     
}    
nav ul li:hover > ul {
    display:inherit;
}    
nav ul ul li {
    width:230px;
    float:none;
    display:list-item;
    position: relative;
}
nav ul ul ul li {
    position: relative;
    top:-60px; 
    left:230px;
}
nav ul ul li {
    border: 1px solid white;
}    
//li > a:after { content:  ' ▼'; }
//li > a:only-child:after { content: ''; }
</style>
</head>
<body>
<html>

<head>
  <meta charset="UTF-8">
  <title>Pure CSS DropDown Menu</title>
  <link href="https://fonts.googleapis.com/css?family=Quicksand|Russo+One&display=swap" rel="stylesheet">
      <link rel="stylesheet" href="style.css">
</head>
<body> 
<?php

    $con=mysqli_connect("localhost","root","","links");
    if(!$con){
    echo "error occured";
    }
    $query="SELECT * FROM cat";
    $result=mysqli_query($con,$query);

?>
<div id="container">
    <nav>
        <ul>
        <?php
        while($row=mysqli_fetch_array($result)){
        $fn_id=$row['id'];    
        $sub_query="SELECT * FROM subcat WHERE catid=".$fn_id;
        $sub_result=mysqli_query($con,$sub_query);
        ?>

            <li><a href="pagination1.php?val=<?php echo $row['id']; ?>"><?php echo $row['name'];?></a>
            <ul>
              <?php
                 while($sub_row=mysqli_fetch_array($sub_result)){


              ?>
            <li><a href="pagination1.php?val=<?php echo $sub_row['id']?>"> <?php echo $sub_row['anme'];?></a></li>

            <?php
                 }
            ?>

            </ul>                

       <?php
        }
        ?>          
        </li>
        </ul>
    </nav>
  <h1>Simple <span>CSS</span> DropDown Menu</h1>

</div>

 <?php


$query='SELECT * FROM data WHERE subcat='.$_REQUEST['val'];
$result=mysqli_query($con,$query);

while($row=mysqli_fetch_array($result)){

?>
<p><?php echo $row['Name'];?></p>
<?php
}
?>

</body>
</html>
</body>
</html>




Aucun commentaire:

Enregistrer un commentaire