<?php
  require("Dbconnect.php");
    //echo "<table id='t1'>"; 
    $cls=$_GET['class'];
    //$count=0;
    echo $cls;
    $qry ="select cls_section_id from class where Class_name='$cls' ";
    $result=mysql_query($qry);
    while($row=mysql_fetch_array($result))
    {
      echo $row['cls_section_id'];
    }
    ?>

http://localhost/ediary/school%20%20diary%20system/subjectassign.php?class=%20NURSERY-A
therefore $cls has value=NURSERY-A and when i am querying it does not result anything and instead of $cls if i use 'NURSERY-A' directly then output is required output,can anyone tell me is there is any error

Recommended Answers

All 2 Replies

Use trim to remove empty spaces:

$cls=trim($_GET['class']);

If you see, there is an empty space in your link between class= and the value, the spaces are encoded with %20.

Ref: http://php.net/manual/en/function.trim.php

Note next time follow the rules of the forum, use a more appropriated title. Bye.

yes i solved it ..thanx for reply

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.