Shilpi
Shilpi

Reputation: 1

Get variable with space?

I want to pass name in get variable. That name contain spaces. So is not working in php.

$facid=$row['Facultyname'];
echo "<a href=tutorials.php?$facid>" . $row['Facultyname']. "</a><p>";

Please help me if Faculty name =A.K. Sharma then it only send A.K.

Upvotes: 0

Views: 2056

Answers (2)

Yan Berk
Yan Berk

Reputation: 14438

Encode the URL:

echo '<a href="tutorials.php?variable_name='.urlencode($row['Facultyname']).'">' 
     . $row['Facultyname']. '</a>';

EDIT: Set a variable name for the GET.

Upvotes: 2

DACrosby
DACrosby

Reputation: 11470

Looks like you're not actually setting a variable after the ?, you're just pasting the value. Try:

$facid = $row['Facultyname'];
echo "<a href='tutorials.php?facid=". urlencode($facid) ."'>". $facid ."</a>";

Upvotes: 0

Related Questions