Home How to write a query to fetch 'Hello World' as 'Hello-World'
Reply: 1

How to write a query to fetch 'Hello World' as 'Hello-World'

Musa Butt
Musa Butt Published in 2018-02-13 18:31:31Z

I'm a bit stuck here. I'm actually rewriting URL, All url who have single word seems to work fine but double word name is not working.

Here is my rewrite code

RewriteEngine on
RewriteRule ^cheap-flights-to-([A-Za-z0-9-]+)/?$ flight_details.php?dest=$1 [NC,L]

My MySQL Database have a table column dest_name with the values like for example "New York, Hong Kong, Kuala Lumpur etc."

Here is my Query

    $flights_query = mysql_query("SELECT * FROM `fares` WHERE `dest_name`='$to_dest' AND `dept_code`='$from_airport' AND `ticket_class`='Y/Y' AND `fare_type`='$flight_type' ORDER BY fare+tax limit 15");

    while($flights_fetch = mysql_fetch_array($flights_query)) {
        $fares = $flights_fetch['fare'] + $flights_fetch['tax'];
        $addpercent = ($fares * $percent) / 100;
        $final_fares = number_format($fares + $addpercent,2);

When I output I add hyphen using PHP function... But it's not fetching data...

bos570 Reply to 2018-02-13 18:47:37Z

I would process the variable before the query. So $to_dest would be cleaned before you used in it the query.

$to_dest = str_replace(" ", "-", $to_dest);
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.325454 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO