close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

URL replace space with hyphen but recordset doesnt recognise...

Thread began 9/30/2013 9:38 pm by Christopher West | Last modified 10/01/2013 2:02 am by Dave Buchholz | 1613 views | 1 replies |

Christopher WestCommunity Expert

URL replace space with hyphen but recordset doesnt recognise...

Hi. ok quick question I am using Product names in my URL
For example a product name would be stored in the database as: Double Print Bookmark

Client is having issues copying the URL link to facebook, and its because of the spaces inbetween words.

I then used
str_replace(' ', '-', after the echo and before the fieldname and this worked as it replaced spaces for hyphens in the URL.

For example:
<div class="button"><a href="product.php?Product=<?php echo str_replace(' ', '-', $row_rsProducts['ProductName']); ?>">View Item</a></div>

However, when the link is pressed and the page goes to the specific URL it of course doesnt display since the recordset on the products.php page is filtering the URL (that now has hyphens) with the original product name in the database (with spaces).

So my question how can I tell the recordset to look up the product but with hyphens included?

Could I somehow set product name to include hyphens just before the recordset query?

Chris

Sign in to reply to this post

Dave BuchholzBeta Tester

Chris,

you need to do something like this in your recordset:

$query_Recordset1 = sprintf("SELECT id, product, REPLACE(product, ' ', '-') AS slug FROM tbl_products WHERE slug = %s", GetSQLValueString($urlVar_Recordset1, "text"));
Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...