0

I am trying to pass value with page link to another page,but the other page is receiving the variable directly not its value.

sender page code

`

<?php 
    if(isset($_POST["view"])){
        $connect = mysqli_connect("localhost","root","","ajmal");

        $Email = $_POST["email"];

        if ($_POST['view'] != '') {
            $update_query = "UPDATE notification SET confirm_ststus=1 WHERE 
            confirm_to='$Email'";
            mysqli_query($connect,$update_query);
        }

        $response='';
        $query="SELECT * FROM notification WHERE confirm_to='$Email' ORDER 
        BY confirm_id DESC LIMIT 5";
        $result=mysqli_query($connect,$query);
        if(mysqli_num_rows($result) > 0){
            while ($row=mysqli_fetch_array($result)) {
                $orderID=$row["orderID"];
                $response.='
                <li>
                    <a href="cusDealerPDF.php?orderID=$orderID">
                        <strong>From : '.$row["confirm_from"].'</strong> 
                       <br/>
                        <small><em>'.$row["confirm_text"].'</em></small>
                    </a>
                </li>
                ';
             }
         }else{
            $response.='<li><a href="" class="text-bold text-italic">No 
           Notification Found</a></li>';
        }
        $query_1 = "SELECT * FROM notification WHERE confirm_ststus=0 AND 
        confirm_to='$Email'";
        $result_1 = mysqli_query($connect,$query_1);
        $count = mysqli_num_rows($result_1);
        $data = array(
            'notification'          => $response,
            'unseen_notification'   => $count
        );
        echo json_encode($data);
    }

`

Receiver page code `

<?php
    if (isset($_GET['orderID'])) {
        echo $_GET['orderID'];
    }
?>

`

at line <a href="cusDealerPDF.php?orderID=$orderID"> I am trying to send value containing by a variable $orderID.The receiver page should print the value contained by variable $orderId but it is directly printing the variable $orderID..what to do?

  • php variables in single quotes `$response.=' ...orderID=$orderID ...'` are not parsed. [`Note: Unlike the double-quoted and heredoc syntaxes, variables and escape sequences for special characters will not be expanded when they occur in single quoted strings.`](http://php.net/manual/en/language.types.string.php#language.types.string.syntax.single) – Sean May 13 '18 at 18:12

1 Answers1

3

Just switch the quotes:

$response.="
<li>
    <a href='cusDealerPDF.php?orderID=$orderID'>
        <strong>From : ".$row["confirm_from"]."</strong> 
        <br/>
        <small><em>".$row["confirm_text"]."</em></small>
    </a>
</li>
";

Learn the difference between Single & Double quotes and other ways too

Thamilhan
  • 13,040
  • 5
  • 37
  • 59