Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Two parameters question

Guest
Oct 05, 2010 Oct 05, 2010

I have a database with around 1600 records as of now. I have several ways to search the db and thought i had all my bases covered. The problem is this. My employer has chosen to name several products the same name or (item number) but differing in that they are different brands or manufacturers. This poses a problem witht he way I have my search results set up obviously. When I search my db for say item number "BAB", I think I get 4 records with item# BAB returned. When I click on one of the items to view the details of the product, my code is assuming all BAB products are the same.

I need to know how to pass not only the item URL parameter, but the brandName URL parameter as well. I know how to pass URL parameters, but obviously I am doing something wrong because I cant get it to work correctly. Here is my query along with my output:


<cfparam name="URL.item" type="any" default="1">
<cfquery name="rsDetails" datasource="rlbulbs">
SELECT a.*, b.brandID, b.brandName
FROM rlbbulbs a, rlbbrand b
WHERE a.brandID = b.brandID
AND a.item = '#URL.item#'
</cfquery>

<h2>Bulb Details for Item #: <cfoutput><span class="yellowBG">#rsDetails.item#</span></cfoutput></h2>
      <p><strong><em>Description:</em></strong> <cfoutput>#rsDetails.bulbDesc#</cfoutput></p>
      <div id="detailTable"><cfoutput>
          <table align="center">
            <tr>
              <td><cfif rsDetails.image1 NEQ "">
                  <a href="images/#rsDetails.image1#" target="_blank"><img src="images/#rsDetails.image1#" alt="#rsDetails.item#" title="#rsDetails.item#"/></a>
                </cfif></td>
            </tr>
          </table>
        </cfoutput>
        <p> </p>
        <table border="0" align="center" cellpadding="2" cellspacing="3">
          <!--- <tr>
    <th scope="row">Bulb ID</th>
    <td><cfoutput>#rsDetails.bulbID#</cfoutput></td>
  </tr> --->
          <tr>
            <th scope="row">Brand</th>
            <td><cfoutput>#rsDetails.brandName#</cfoutput></td>
          </tr>
          <tr>
            <th scope="row">Price</th>
            <td><cfoutput>#dollarFormat(rsDetails.price)#</cfoutput> for <cfoutput>#rsDetails.qtyPerPrice#</cfoutput> unit/s</td>
          </tr>
          <tr>
            <th scope="row">Wattage</th>
            <td><cfoutput>#rsDetails.wattage#</cfoutput></td>
          </tr>
          <tr>
            <th scope="row">Voltage</th>
            <td><cfoutput>#rsDetails.voltage#</cfoutput></td>
          </tr>
          <tr>
            <th scope="row">Base</th>
            <td><cfoutput>#rsDetails.base#</cfoutput></td>
          </tr>
          <tr>
            <th scope="row">Glass</th>
            <td><cfoutput>#rsDetails.glass#</cfoutput></td>
          </tr>
          <tr>
            <th scope="row">Filament</th>
            <td><cfoutput>#rsDetails.filament#</cfoutput></td>
          </tr>
          <tr>
            <th scope="row">Avg Life</th>
            <td><cfoutput>#rsDetails.avgLife#</cfoutput> hours</td>
          </tr>
          <tr>
            <th scope="row">Beam Angle</th>
            <td><cfoutput>#rsDetails.beamAngle#</cfoutput></td>
          </tr>
          <tr>
            <td colspan="2" align="center"><a href="../search.cfm">Search for another bulb</a></td>
          </tr>
        </table>
      </div>


Thanks for any help in advance!

5.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 05, 2010 Oct 05, 2010

Can you not add a proper primary key to the tables in question & use that instead? There are performance and maintenance considerations as well as the accessibility issues you already have here.

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 05, 2010 Oct 05, 2010

Hi Adam, and Dave. Thanks for the replies. Yes I do already have primary keys set up in my database. I assumed that I need to pass item number and brand name for SEO purposes correct? instead of just passing a primary key parameter that is useless for search engines like google.

Again, as it is now, its passing a url that likes this:

http://www.teed-younger.com/bulbsDetail.cfm?item=BAB

but once again by passing BAB that may or may not be unique, I need a way to filter out repeats in BAB.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 05, 2010 Oct 05, 2010

I don't know if this is going to make that much of an SEO difference - as long as you have good markup (primarily a title) that represents the page contents, that's the most important thing. Search engines are pretty good about that stuff nowadays.

But in any case, you can just include multiple URL parameters:

http://www.teed-younger.com/bulbsDetail.cfm?item=BAB&brandName=WHATEVER

Dave Watts, CTO, Fig Leaf Software

Dave Watts, Eidolon LLC
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 05, 2010 Oct 05, 2010

Yeah I don't believe ?id=1 is any more or less SEO-friendly than ?prodcode=foo&prodvariant=bar. As long as the search engine can •find• the page (so there's a published URL to it), it'll index it. The content of the page is far far more important than the URL to get to it.

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 05, 2010 Oct 05, 2010

To expand on Dave's answer, as well as the product and brand name, you could just add the table unique key to the URL.  This is probably a pretty low level SEO item, especially if your names are not more descriptive then what you showed in your example code.

I.E.

www.myProductPage.cfm?product=MomsApplePie&brand=MamaJeter&key=666

P.S.

Nice to see you outside of your usual haunt at House of Fusion, Dave.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 05, 2010 Oct 05, 2010
function(){return A.apply(null,[this].concat($A(arguments)))}

ilssac wrote:

To expand on Dave's answer, as well as the product and brand name, you could just add the table unique key to the URL.  This is probably a pretty low level SEO item, especially if your names are not more descriptive then what you showed in your example code.

I.E.

www.myProductPage.cfm?product=MomsApplePie&brand=MamaJeter&key=666

P.S.

Nice to see you outside of your usual haunt at House of Fusion, Dave.

Well to be clear, the item name IS very specific to what people might search for when searching for out products. BAB for instance, when searched for in google along with light bulb, would return specific results.  In other words BAB is not a generic item name that has been given to one our products internally.

Thats why I thought, along with page titles which are dynamically driven also, that the item name needed to be included in the url as a parameter.

And so thats what has brought up the issue now of having more than one records of BAB in the db..lol

Yeah I don't believe ?id=1 is any more or less SEO-friendly than ?prodcode=foo&prodvariant=bar. As long as the search engine can •find• the page (so there's a published URL to it), it'll index it. The content of the page is far far more important than the URL to get to it.

Well I'm not sure then. All my product pages are created dynamically and I thought that might be an issue for SEO as I have read. Either way, I have to pass some parameter so that the details of a particular record shows, so I thought it might as well be something that might make sense to a user and a search engine.

Man I'm confused!! lol

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 05, 2010 Oct 05, 2010

Thats why I thought, along with page titles which are dynamically driven also, that the item name needed to be included in the url

as a parameter.

A lot of SEO advice falls in the "diminishing returns" category. It

definitely doesn't "need" to be included, and if your page content is

relevant to the search query, it should come up in searches. Embedding

the search terms in the URL might add a tiny smidgen of relevance, but

not a significant amount.

Dave Watts, CTO, Fig Leaf Software

http://www.figleaf.com/

http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on

GSA Schedule, and provides the highest caliber vendor-authorized

instruction at our training centers, online, or onsite.

Dave Watts, Eidolon LLC
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 05, 2010 Oct 05, 2010

Don't worry about your url variables making sense to users.  It's lots of work with few if any results.

If you do decide to pass product names, make sure you url encode them.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 06, 2010 Oct 06, 2010

lol Well I would love nothing better than to make things easier on myself, but my employer insists that there needs to be the bulb name in the URL. This was how he did his static site and its worked really well. Whether or not the actual URL had anything to do with his high page rankings I dont know, but regardless he does have very good search rankings so who am I to argue this point.

Now I have managed to pass 2 URL variables,but didnt have the desired results I was looking for.

Well I thought I had. I changed something trying to get it to work correctly, but now I get an error about unknown column "item#"

Here is my new query.


<cfparam name="URL.item" type="any" default="1">
<cfparam name="URL.brandID" type="any" default="1">
<cfquery name="rsDetails" datasource="rlbulbs">
SELECT a.*, b.brandID, b.brandName
FROM rlbbulbs a, rlbbrand b
WHERE a.brandID = #URL.brandID#
AND a.item = #URL.item#
</cfquery>


WHen I hover over a result in my search query, I can see it is passing two url parameters..."?item="BAB"&brandName="GE"

Thanks again for all the help.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 06, 2010 Oct 06, 2010

AHHGGGG lol ok I got it working! Sorry to bother you guys. I really appreciate all your help! Just one of those times when you draw a blank and have to get your mind off of it for a while. I knew something had to be missing so I figured out I wasnt including a condition in my where clause to pull the bulbs unique to the brandID I wanted. Thanks again!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 06, 2010 Oct 06, 2010

You don't want to wrap the parameters in quotes. You should end up having something like this:

?item=BAB&brandName=GE

And, as one of the other posters mentioned, you want to URL-encode them using the URLEncodedFormat function before embedding them in the URL.

Dave Watts, CTO, Fig Leaf Software

Dave Watts, Eidolon LLC
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 06, 2010 Oct 06, 2010

Dave Watts wrote:

You don't want to wrap the parameters in quotes. You should end up having something like this:

?item=BAB&brandName=GE

And, as one of the other posters mentioned, you want to URL-encode them using the URLEncodedFormat function before embedding them in the URL.

Dave Watts, CTO, Fig Leaf Software

Yes Dave, lol sorry, I included the quotes for reference here. I dont actually have quotes around my parameters.

Now as far as the URLencoded function. I'm a little confused as to where to include this function. Please, can you explain further? Or at least point me to something to read up on it. Thanks again!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 06, 2010 Oct 06, 2010

It would look something like this:

<cfset item = "this is my item">

<cfset brandName = "this is my brand name">

<cfoutput>

<a href="http://whatever/show.cfm?item=#URLEncodedFormat(item)#&brandName=#URLEncodedFormat(brandName)#">link</a>

</cfoutput>

Dave Watts, CTO, Fig Leaf Software

http://www.figleaf.com/

http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on

GSA Schedule, and provides the highest caliber vendor-authorized

instruction at our training centers, online, or onsite.

Dave Watts, Eidolon LLC
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 06, 2010 Oct 06, 2010

Ok I added the code you suggested and get no errors, so thats good I think lol

What does this do? I know the <cfqueryparam> keeps people from "hacking" my database by way of a form, but the page here contains no forms to pass the URL params. here is what I have now:


<cfset item ="item">
<cfset brandName="brandName">
<cfparam name="FORM.item" default="" type="String">
<cfparam name="FORM.brandName" default="" type="String">
<cfparam name="FORM.base" default="" type="String">
<cfparam name="FORM.glass" default="" type="String">
<cfparam name="FORM.wattage" default="" type="String">
<cfparam name="FORM.voltage" default="" type="String">

<td><a href="bulbsDetail.cfm?item=#URLEncodedFormat(rsSearch.item)#&brandName=#URLEncodedFormat(rsSearch.brandName)#">#item#</a></td>

Thanks again for all your help!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 06, 2010 Oct 06, 2010

The URLEncodedFormat function does what it says on the tin: it encodes strings so that they don't include any characters which are either not acceptable in URLs or are URL metacharacters. Spaces, for example, aren't acceptable for use within URLs even though most modern browsers let you use them - the browser automatically encodes for you. Not all browsers do this, of course, so you want to do it to avoid the problem in the first place. Metacharacters are characters that have some special meaning within a URL, like ? or &. If you had a string containing one of those, the server might get very confused when receiving it in the URL.

And you're welcome!

Dave Watts, CTO, Fig Leaf Software

http://www.figleaf.com/

http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on

GSA Schedule, and provides the highest caliber vendor-authorized

instruction at our training centers, online, or onsite.

Dave Watts, Eidolon LLC
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 06, 2010 Oct 06, 2010

Awesome! thanks for the information and education! lol I noticed someone earlier said you frequented houseoffusion. I like that site as well, and think I remember seeing you there, but wish it was more active! Anyway, thanks and see you around!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 06, 2010 Oct 06, 2010

The cf-talk list is pretty active, actually.

Dave Watts, CTO, Fig Leaf Software

http://www.figleaf.com/

http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on

GSA Schedule, and provides the highest caliber vendor-authorized

instruction at our training centers, online, or onsite.

Dave Watts, Eidolon LLC
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 06, 2010 Oct 06, 2010

Ok one more question while I have you lol. I now notice the unacceptable characters you mentioned have been replaced with "%" sign. Again, my employer insists on seeing a readable url, so my question is, will I need to do some URL rewrites now? I had downloaded the URLrewrite module a few weeks ago thinking I may need to, but with only passing the one parameter I origianlly had, and seeing that I was indeed ranked pretty high withougt converting the url, I decided to not use it. I know before I even show him this, he will not like the odd looking characters in his item names.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 06, 2010 Oct 06, 2010

Those characters are automatically escaped by search engines for SEO purposes, and by servers when receiving the data (in your action page). A well-formed URL is much more important than a human-readable one, in that one will work in browsers and the other may not.

If that's not an acceptable answer to your employer, you could alternatively replace spaces with dashes or underscores, but then you'd have to make sure to differentiate those dashes or underscores from actual dashes or underscores you have in those fields. There's no function to automatically replace spaces with dashes or underscores, so you'd have to do that yourself, and there's no function to automatically replace dashes or underscores with spaces in your action page, so you'd have to do that yourself too.

Dave Watts, CTO, Fig Leaf Software

http://www.figleaf.com/

http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on

GSA Schedule, and provides the highest caliber vendor-authorized

instruction at our training centers, online, or onsite.

Dave Watts, Eidolon LLC
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 06, 2010 Oct 06, 2010

I understand, thanks. Yes he has many products with "/" in the actual names. for example. a

popular product would be "60K19/DL" or "100A/RS-12V" in which both products would look like 60K19%DL and 100A%RS%12V respectively.

Thanks again, and I definately have some researching to do!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 07, 2010 Oct 07, 2010

The thing is... urlEncodedFormat() will only escape things that need to be escaped.  It's not valid to have "/" characters in a URL anywhere other than in the path to the document.  So by insisting on having these unencoded, your boss is running the risk - small though it is - of some remote agent such as a search engine crawler going "not a valid URL... forget it".  So that sort of thing works against SEO.

For no good or sensible reason, he's cutting off his nose to spite his face.

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 07, 2010 Oct 07, 2010

Adam, yes I understand and agree. I have been meaning on addressing this issue with him. I am just wondering about what can be used in place of "/" or "-" in product names, as obviously they are not valid characters in urls. Maybe an underscore would be ok? What would you suggest?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 07, 2010 Oct 07, 2010

Read the RFC:

http://tools.ietf.org/html/rfc1738

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 07, 2010 Oct 07, 2010

Underscores and hyphens are both ok. From the RFC that Adam mentioned:

"Thus, only alphanumerics, the special characters "$-_.+!*'(),", and reserved characters used for their reserved purposes may be used unencoded within a URL."

Dave Watts, CTO, Fig Leaf Software

http://www.figleaf.com/

http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on

GSA Schedule, and provides the highest caliber vendor-authorized

instruction at our training centers, online, or onsite.

Dave Watts, Eidolon LLC
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources