This question already has answers here:
Question mark in the middle of a URL variable
(3 answers)
Closed 8 years ago.
i want to pass value that contain question mark
i have 2 php example example1.php and example2.php
in my example1.php the code like this
<a href="example2.php?title=what is this?" />
in my example2.php the code like this
<php
if(isset($_GET['title']))
{
$title = $_GET['title'];
echo $title;
}
?>
but in example2.php the title become like this what is this the question mark disappear
i already try to use str_replace my question mark become like this what is this"?" but still same at example2.php the question mark disappear
please help me how to pass value that contain question mark
thanks
change <a href="example2.php?title=what is this?" /> into
<a href="example2.php?title=what is this%3F" />
then add
<?php
if(isset($_GET['title']))
{
$title = $_GET['title'];
echo $title;
}
?>
this will work for you.
Related
This question already has answers here:
get file name for url php
(2 answers)
Closed 3 years ago.
I want to separate IMDb id from the link
my php code is this
<?php print $movie_info[0]->imdb_link; ?>
the URL seems like this on every page .
https://imdb.com/title/tt1206885
i want to show this id separate from the url on my page => tt1206885
please help me
i try but fail to extract the id
<?php if($movie_info[0]->imdb_link){?>
ID <?php $str = explode("/",$movie_info[0]->imdb_link);
/* if url in php variable then $str = explode("/",$imdb_id); */
print $str[count($str)-2];
?>">
<?php }?>
$link_array = explode('/', $movie_info[0]->imdb_link);
$id = end($link_array);
This question already has answers here:
What is the difference between client-side and server-side programming?
(3 answers)
Closed 4 years ago.
I am trying to add if statemenet into $html variable. But it see php as a html tag. how can add this statement. Thanks
$html = '
<?php if (x=y):?>
<div>
Help me )
</div>
<?php endif ?>
';
Try following
$html = '';
if(x==y):
$html .= '<div> Help me )</div>';
endif;
You can do without closing php tags.
Edited
After #MichaĆSkrzypek comment I have edited and fix mistake in if statement
What you are trying to do is impossible. If you would want to echo the var, you would put <?php inside of <?php, which must result in an error. Only add
<div>
Help me )
</div>
to a var.
This question already has answers here:
How to echo inside html tags
(6 answers)
Closed 5 years ago.
Script 1.
add_action('asgarosforum_after_post_author', 'my_function_asgaros_cabinet', 10, 1);
function my_function_asgaros_cabinet($author_id) {
$userData = get_userdata($author_id);
if (!empty($userData) && !empty($userData->description)) {
echo $userData->description;
}
}
Script 2.
I want to put this in script 1 and put ''description'' in the end of that link.
How to do that and whats the right way/code? Cause i think my code is wrong.
<iframe src="http://test.com/me.php?sid='echo $userData->description'"></iframe>
Try with adding the php tag:
<iframe src="http://test.com/me.php?sid=<?php echo $userData->description?>"></iframe>
or
You can try to write the all iframe tag with php:
echo '<iframe src="http://test.com/me.php?sid='. $userData->description .'"></iframe>'
This question already has answers here:
How to add url parameter to the current url?
(7 answers)
Closed 7 years ago.
I have an search method who redirect to something like this:
mysite.ro/search.php?a=1&b=2&c=3
When i have pagination i need to redirect me to something like this:
mysite.ro/search.php?a=1&b=2&c=3&page=2
I dont know the solution to have an href who redirect to page=2 and keep the same search criteria.
I tried <a href="&page=2"> and href="<?php echo $_SERVER[REQUEST_URI];?>&page=1" not usefull both.
Try this, Its worked for me.
<?php
$actual_link = '';
$delimiter = '?&page=';
$link = array();
$actual_link = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$links = explode($delimiter, $actual_link);
?>
<a href="<?php echo $links[0];?>?&page=1" >Link </a>
This question already has answers here:
What is the "?" symbol in URL used for in php?
(7 answers)
Closed 9 years ago.
Sorry if this is a stupid question but I want to include two variables in an href
the href is not in a form
<div class="button">
View
</div>
int he page I am sending it to i have a Get method
if (isset($_GET['Name']) && isset($_GET['pid'])) {
$id2 = $_GET['Name'];
$id = $_GET['pid'];
Summary
I want to include $id in the a href so i will be able to get both name and id in the page product.php
You can append as many URL parameters as you like using &:
<a href="<?php fetchdir($ipages); ?>product.php?Name=<?php echo $name; ?>&id=<?php echo $id; ?>" ...
product.php?Name=$name&pid=$pid
You can use & to add two or more GET parameters to a URL.
One good way to build a property encoded is to use the http_build_query function, this will ensure that the data sent in the request is properly encoded.
<?php
$qstr = http_build_query(array("Name"=>$row["Name"], "id"=>$row["pid"]));
?>
<a href="<?php fetchdir($ipages) ?>product.php?<?= $qstr ?>">
This of course can also be done inline
<a href="<?php fetchdir($ipages) ?>product.php?<?= http_build_query(array("Name"=>$row["Namw"], "id"=>$row["pid"])) ?>">