Jump to content

HTTP_REFERER


Stephen68

Recommended Posts

Ok I have a script that get the value from HTTP_REFERER and stores in into my MySQL DB. This part works great but it will not wrap when I go to display the information into a table field. I'm not really sure why this is

 

   //Print out the referred from pages that are DISTINCT
   //Start the table layout for display
   echo "<p>";
   echo "<table  border='1'>";
   echo "    <tr>";
   echo"          <td valign='top' align='center'>Page Referred From</td>";
   echo"          <td valign='top' align='center'>Percentage Referred From</td>";
   echo"     </tr>";


   while ($array = mysql_fetch_array($referrerPages)) {
   //Run a query that will count the  number of times the page has referred a user
   $query = mysql_query("SELECT from_page FROM statTracker WHERE from_page = '".$array[0]."'") or die(mysql_error());

   $referredCount = mysql_num_rows($query);

   $percentage = $referredCount / $hits * 100;

   echo "<tr>";
   echo "   <td>".$array[0]."</td>";
   echo "   <td>".round($percentage,2)."</td>";
   echo "</tr>";

   }//End of while loop for referred

   //End the table for layout of referred
   echo "</table>";

 

Here is a quick view of the code I'm kind of working with, it just simple stuff I'm playing with.

Any help would be great!

 

Stephen

Link to comment
Share on other sites

You need to define your table width, and the <td> width. Not defining a width for <td> tells it to keep expanding the cell to accommodate the data. When working with tables, you need to exercise some control over them. Just throwing a table out there with no restrictions can get you unexpected results real quick. Google some table tutorials and spend a few hours learning.

 

Alternatively, you could force some line breaks into the referer strings coming out of MySQL, but it's best to fix the real problem, which is undefined table constraints.

 

PhREEEk

Link to comment
Share on other sites

Ya that is what I thought at first to but when I put the table width in it still would not wrap the results I got from a Yahoo.com referer. Here is what the string looks like in the DB.

 

http://search.dal.ca/search?q=bio+diesel&btnG=Search&sitesearch=&entqr=0&output=xml_no_dtd&sort=date%3AD%3AL%3Ad1&client=test_frontend&dal_domain=dalnews.dal.ca&submit=______&ud=1&oe=UTF-8&ie=UTF-8&pr

 

Don't even think it will wrap in this post lol, any other ideas??

 

Thank you for you help in this

 

Stephen

Link to comment
Share on other sites

You could chop out only the part you want... do you really need all the data tagged onto the end of the referer?

 

Going even further, you could use a javascript snippet to shorten it, and then allow a mouse hover to reveal it in a 'tool tip' dialog box.

 

By the way, the reason it won't wrap is because there is no white space in it...

 

Which then means we could -insert- white space every n number of characters, which would then allow it to wrap...

 

You got a lotta options, really... but you need to be firm on what exactly you need displayed versus what might be garbage that can be tossed out.

 

PhREEEk

Link to comment
Share on other sites

All I really need is the first part of the URI I guess, I really don't need all that other info. but I'm not good at regex.

Maybe I'll look into doing a regex up to the first ? and only have that stored in the DB.

 

Thanks for your guys time in this and if you know the regex that I need.... :) hehe

 

Stephen

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.