开发者

Create clickable URL in PHP

开发者 https://www.devze.com 2023-04-07 19:11 出处:网络
Trying to create a clickable URL in PHP. 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. At right of this page

Trying to create a clickable URL in PHP. 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. 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. 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 开发者_JAVA技巧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. I can't even read the code you've posted, so that's the only answer I can give.


Instead of wrapping your in an , use the onclick attribute of the tag.

<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>


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

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
------
------
------
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消