Stephen68 Posted November 22, 2007 Share Posted November 22, 2007 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 Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted November 22, 2007 Share Posted November 22, 2007 you need to set the width of your table and td; then it should wrap with the width of the table. Quote Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted November 22, 2007 Share Posted November 22, 2007 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 Quote Link to comment Share on other sites More sharing options...
Stephen68 Posted November 22, 2007 Author Share Posted November 22, 2007 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 Quote Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted November 22, 2007 Share Posted November 22, 2007 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 Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 22, 2007 Share Posted November 22, 2007 you can use the wordwrap function in php http://php.net/wordwrap Quote Link to comment Share on other sites More sharing options...
Stephen68 Posted November 22, 2007 Author Share Posted November 22, 2007 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.