Jump to content

MarkBad311

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

MarkBad311's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. This is gonna be tuff. I have an existing function in my library that querys the db and generates these links depending on the 'bar' field . **Problem I am making these results fit in to a one line button on a side naviagtion menu example :: [a href=\"http://www.eriescene.com\" target=\"_blank\"]www.eriescene.com[/a]. the second nav portion is two lines. some of the titles are too long. **Solution use some kind of regular expression: 1.... starts from the begining of the title and counts in 19 characters 2.... and replaces the next two charcters with .. (two periods). 3.... Forgets about the rest. [!--coloro:#FF9900--][span style=\"color:#FF9900\"][!--/coloro--]Note: Must work on whitespace, letters, numbers, special characters.[!--colorc--][/span][!--/colorc--] Here is the Existing Link Generating PHP/MYSQL CODE [b][!--coloro:#009900--][span style=\"color:#009900\"][!--/coloro--] ///////////////////////////////////////////// //Links to single Events/////////////// /////////////////////////////////////////// function sidemenu($connection) { global $nav_block; $table_name = "events"; $sql = "SELECT id, bar FROM $table_name WHERE `date` BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 DAY) and DATE_ADD(CURDATE(), INTERVAL 20 DAY) ORDER BY 'bar'"; $result = @mysql_query($sql) or die(mysql_error()); $num = @mysql_num_rows($result); if ($num < 1) { $nav_block = "<p>I am sorry there is no results</p>"; } else { $nav_block .= "<ul class=\"menu\">"; //if results are found loop through them and make a form selection block list. while ($row = mysql_fetch_array($result)) { $id = $row['id']; $bar = $row['bar']; $nav_block .= "<li><a href=\"http://www.eriescene.com/index.php?id=$id\">$bar</a></li>"; } $nav_block .= "</ul>"; } } [!--colorc--][/span][!--/colorc--][/b] [!--coloro:#009900--][span style=\"color:#009900\"][!--/coloro--]$bar[!--colorc--][/span][!--/colorc--] is the variable we'll need to modify. something like [!--coloro:#009900--][span style=\"color:#009900\"][!--/coloro--]$bar = $preg_replace('findit, limit it and add two period chacters, $bar);[!--colorc--][/span][!--/colorc--] Try as I may stinkin regex's get me everytime. Thank you to anyone that can help me... As I can't get it right and it is way to complicated for my skill level :-) Thanks again
×
×
  • 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.