简体   繁体   English

在PHP中创建可点击的URL

[英]Create clickable URL in PHP

Trying to create a clickable URL in PHP. 尝试在PHP中创建可点击的URL。 If you visit www.wheels4rent.net/test00.html and input location and date clicking the 'quote' will take you to the list_car5.php page. 如果您访问www.wheels4rent.net/test00.html并输入位置和日期,请单击“报价”将您带到list_car5.php页面。 At right of this page is a 'book now' button that does not work and the text hyperlink below this. 此页面右侧是“立即预订”按钮,该按钮不起作用,并且该按钮下方的文本超链接。 problem is when clicking the text hyperlink instead of giving me the www.thrifty.co.uk URL it gives me www.wheels4rent.net/www.thrifty.co.uk URL which obviously does not display webpage. 问题是单击文本超链接而不是给我www.thrifty.co.uk URL时,它给了我www.wheels4rent.net/www.thrifty.co.uk URL,该URL显然不显示网页。 Please assist. 请协助。 Also i need to also create the text hyperlink within my 'book now' button instead. 另外,我还需要在“立即预订”按钮内创建文本超链接。 below is code 下面是代码

$url = (string)$car->book;

echo "<tr><td width=200px><' align='right' style='padding:1px; width:100px'><b>".$car->cartype."</b><br>".$car->carsipp."<br>".$car->transmission."</td><td><b>".$car->carexample."</b></td><td><b>&pound;".$car->price."
</b><br>Unlimited Miles</b><br><a href='$url'><input type='submit' name='Book Now' value='Book Now'><br>book now<br></a></td></tr>"; 
}
echo "</table>";

You need to add http:// to the beginning of the URL in the <a> tag. 您需要在<a>标记的URL开头添加http://。 I can't even read the code you've posted, so that's the only answer I can give. 我什至无法阅读您发布的代码,所以这是我唯一能给出的答案。

single quotes doesn't read variables. 单引号不会读取变量。 So you could either write the whole html part in echo or you can simply close the php tag and enter the html code and then continue with your php code 因此,您可以在echo中编写整个html部分,也可以直接关闭php标签并输入html代码,然后继续执行php代码

for ex: 例如:

    <?php
echo "<input type='submit' value='submit' onclick='<script>window.location('http://www.google.com')</script>'";
?>

or simply: 或者简单地:

    <?php
-----//php code here
----
----
?>
<input type="submit" value="submit" onclick="<script>window.location('http://www.google.com')</script>"/>
<?php
------
------
------
?>

Instead of wrapping your in an , use the onclick attribute of the tag. 不用将您的代码包装在中,而是使用标记的onclick属性。

<input type='submit' name='Book Now' value='Book Now' 
   onclick="javascript:window.location('http://www.thrifty.co.uk')" />
<a href="http://www.thrifty.co.uk">Book Now</a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM