NoDoze Posted March 27, 2007 Share Posted March 27, 2007 I have emails and URLs store in a mysql database, but when I call the info up on a php page, they don't show up as a link. How do I get them to be links instead of just written out as text? Thanks! Link to comment https://forums.phpfreaks.com/topic/44542-email-or-url-link/ Share on other sites More sharing options...
scarface83 Posted March 27, 2007 Share Posted March 27, 2007 <?php "<a href=>", $linkfrom db, "Contact me</a>" ?> Link to comment https://forums.phpfreaks.com/topic/44542-email-or-url-link/#findComment-216343 Share on other sites More sharing options...
NoDoze Posted March 27, 2007 Author Share Posted March 27, 2007 cool! thanks! Link to comment https://forums.phpfreaks.com/topic/44542-email-or-url-link/#findComment-216355 Share on other sites More sharing options...
NoDoze Posted June 8, 2007 Author Share Posted June 8, 2007 Sorry, I thought this was what I was looking for, and it looked correct at first, but after thinking more about it, this is incorrect. Let me provide an example of what I'm asking. I have this paragraph being submited by form into a mysql database as "section1": "If you are interested in applying to this position, please send to [email protected] or visit http://www.domain.com for more information" Then when this info is called up onto a html page via, example: <td width='682' align='left' class='table-header'>$section1<br><br></td> On the html page the email address and url show up as text and not links. How do I get the email address and url to show up as links? The above suggestion is if ONLY the URL or email is stored in the DB, and will be on the html page as a link. But in the case I need, I have the urls in the middle of text. Thanks again. Link to comment https://forums.phpfreaks.com/topic/44542-email-or-url-link/#findComment-270999 Share on other sites More sharing options...
chocopi Posted June 8, 2007 Share Posted June 8, 2007 You could try: <?php $value = '[email protected]'; $check = stripos($value, '@'); if ($check == true) { echo ("<a href=\"mailto:$value\">$value</a>"); } else if ($check == false) { echo ("<a href=\"$value\">$value</a>"); } ?> Hope it helps, ~ Chocopi Link to comment https://forums.phpfreaks.com/topic/44542-email-or-url-link/#findComment-271094 Share on other sites More sharing options...
NoDoze Posted June 8, 2007 Author Share Posted June 8, 2007 Hmmm....interesting. That would ork well if it was the same email address and web link. But in this case the URLs and email addresses are different from section to section. Link to comment https://forums.phpfreaks.com/topic/44542-email-or-url-link/#findComment-271111 Share on other sites More sharing options...
chocopi Posted June 8, 2007 Share Posted June 8, 2007 Well if you replace $value with your sql statement it should work fine Link to comment https://forums.phpfreaks.com/topic/44542-email-or-url-link/#findComment-271117 Share on other sites More sharing options...
Dragen Posted June 8, 2007 Share Posted June 8, 2007 You'd probably want to be accurate than that. What if they happen to type in '@' somewhere in the string? Link to comment https://forums.phpfreaks.com/topic/44542-email-or-url-link/#findComment-271159 Share on other sites More sharing options...
Dragen Posted June 8, 2007 Share Posted June 8, 2007 hey, I've been really bored so I just wrote you a check method for emails and urls. If the url doesn't contain http:// then it adds it in, because many people forget it, which would cause the page to open incorrectly. <?php $string = 'fghfg gvfhfghm www.mydomain.co.uk gmje7gfjk 654hjk [email protected] hgoi gnmguyhb9 o http://www.mydomain.co.uk hgf'; $ex = explode(' ', $string); foreach($ex as $key => $value){ if(ereg("^[^@]{1,64}@[^@]{1,255}$", $value)){ $value = str_replace($value, '<a href="mailto:' . $value . '">' . $value . '</a>', $value); }elseif(ereg('^((http|https)://)?(((www\.)?[^ ]+\.([com|org|net|edu|gov|us]|[co\.uk]))|([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+))([^ ]+)?$', $value)){ if(preg_match('(http|https)', $value)){ $value = str_replace($value, '<a href="' . $value . '" target="_blank">' . $value . '</a>', $value); }else{ $value = str_replace($value, '<a href="http://' . $value . '" target="_blank">' . $value . '</a>', $value); } } $text[] = $value; } $string = implode(" ", $text); echo $string; ?> I've tested it and it works. Just pass everything through it as $string and it gets outputted back as $string for the echo. Link to comment https://forums.phpfreaks.com/topic/44542-email-or-url-link/#findComment-271172 Share on other sites More sharing options...
NoDoze Posted June 18, 2007 Author Share Posted June 18, 2007 OMG! Thank you! This is AWESOME! ...but how would I impliment it? Currently a form inserts text into the database, ex: sec1 on the form = sec1 into the database = then is pulled from the database by $sec1 How would I route this or include the code you provided? Would I just substitute line #2 to be: $string = $sect1 then just dump the code you provided where the text is to appear? Link to comment https://forums.phpfreaks.com/topic/44542-email-or-url-link/#findComment-277055 Share on other sites More sharing options...
Dragen Posted June 18, 2007 Share Posted June 18, 2007 This should work. Just replace all instances of $string with $sect1 (and remove the line which set what $string was as it's not needed) <?php $ex = explode(' ', $sect1); foreach($ex as $key => $value){ if(ereg("^[^@]{1,64}@[^@]{1,255}$", $value)){ $value = str_replace($value, '<a href="mailto:' . $value . '">' . $value . '</a>', $value); }elseif(ereg('^((http|https)://)?(((www\.)?[^ ]+\.([com|org|net|edu|gov|us]|[co\.uk]))|([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+))([^ ]+)?$', $value)){ if(preg_match('(http|https)', $value)){ $value = str_replace($value, '<a href="' . $value . '" target="_blank">' . $value . '</a>', $value); }else{ $value = str_replace($value, '<a href="http://' . $value . '" target="_blank">' . $value . '</a>', $value); } } $text[] = $value; } $sect1 = implode(" ", $text); echo $sect1; ?> Link to comment https://forums.phpfreaks.com/topic/44542-email-or-url-link/#findComment-277104 Share on other sites More sharing options...
NoDoze Posted June 18, 2007 Author Share Posted June 18, 2007 Had to tweak it ever so slightly to work on the page but IT WORKED LIKE A DREAM! AWESOME! PLEANTY THANKS! Link to comment https://forums.phpfreaks.com/topic/44542-email-or-url-link/#findComment-277163 Share on other sites More sharing options...
Dragen Posted June 18, 2007 Share Posted June 18, 2007 glad I could help Link to comment https://forums.phpfreaks.com/topic/44542-email-or-url-link/#findComment-277165 Share on other sites More sharing options...
NoDoze Posted June 20, 2007 Author Share Posted June 20, 2007 Ok, thanks for the above help....but now I was thinking....an extension from that... Here is my code for this one: <? include 'config.php'; include 'opendb.php'; ?> <? $query="SELECT * ,DATE_FORMAT(indate, '%b %d %Y') AS findate FROM jobs ORDER BY indate DESC"; if(isset($_GET['sortby'])){ $query .= " ORDER BY '" . $_GET['sortby'] . "'"; } $result=mysql_query($query); mysql_close(); $num=mysql_numrows($result); $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $findate=mysql_result($result,$i,"findate"); $title=mysql_result($result,$i,"title"); $sec1h=mysql_result($result,$i,"sec1h"); $sec1t=mysql_result($result,$i,"sec1t"); $sec2h=mysql_result($result,$i,"sec2h"); $sec2t=mysql_result($result,$i,"sec2t"); $sec3h=mysql_result($result,$i,"sec3h"); $sec3t=mysql_result($result,$i,"sec3t"); $sec4h=mysql_result($result,$i,"sec4h"); $sec4t=mysql_result($result,$i,"sec4t"); $ex = explode(' ', $sec4t); foreach($ex as $key => $value){ if(ereg("^[^@]{1,64}@[^@]{1,255}$", $value)){ $value = str_replace($value, '<a href="mailto:' . $value . '">' . $value . '</a>', $value); }elseif(ereg('^((http|https)://)?(((www\.)?[^ ]+\.([com|org|net|edu|gov|us]|[co\.uk]))|([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+))([^ ]+)?$', $value)){ if(preg_match('(http|https)', $value)){ $value = str_replace($value, '<a href="' . $value . '" target="_blank">' . $value . '</a>', $value); }else{ $value = str_replace($value, '<a href="http://' . $value . '" target="_blank">' . $value . '</a>', $value); } } $text[] = $value; } $sec4t = implode(" ", $text); print "<tr>"; print "<td width='450' colspan='2' align='left'><hr></td>"; print "</tr>"; print "<tr>"; print "<td width='682' align='left' class='table-header'>$title<br><br></td><td width='120' align='left'>$findate</td>"; print "</tr>"; print "<tr>"; print "<td colspan='2' align='left'><b>$sec1h</b><br>$sec1t<br><br></td>"; print "</tr>"; print "<tr>"; print "<td colspan='2' align='left'><b>$sec2h</b><br>$sec2t<br><br></td>"; print "</tr>"; print "<tr>"; print "<td colspan='2' align='left'><b>$sec3h</b><br>$sec3t<br><br></td>"; print "</tr>"; print "<tr>"; print "<td colspan='2' align='left'><b>$sec4h</b><br>$sec4t<br><br></td>"; print "</tr>"; ++$i; } ?> <?php include 'closedb.php'; ?> As you can see I have multiple sections, in a loop to sort by column headers... though I need the link code you provided to scan through each section for urls and emails. As you can probably guess, it works fine for one section, but if I add your code multiple times for each section...it loops the first section over and over. How can I amend or add your code so that it scans every section for urls and emails? Thanks again! Link to comment https://forums.phpfreaks.com/topic/44542-email-or-url-link/#findComment-278548 Share on other sites More sharing options...
Dragen Posted June 20, 2007 Share Posted June 20, 2007 I haven't tested this at all but try this: <?php include 'config.php'; include 'opendb.php'; $query="SELECT * ,DATE_FORMAT(indate, '%b %d %Y') AS findate FROM jobs ORDER BY indate DESC"; if(isset($_GET['sortby'])){ $query .= " ORDER BY '" . $_GET['sortby'] . "'"; } $result=mysql_query($query); mysql_close(); $num=mysql_numrows($result); $i=0; while ($i < $num) { $id = mysql_result($result,$i,"id"); $findate = mysql_result($result,$i,"findate"); $title = mysql_result($result,$i,"title"); $secs['sec1h'] = mysql_result($result,$i,"sec1h"); $secs['sec1t'] = mysql_result($result,$i,"sec1t"); $secs['sec2h'] = mysql_result($result,$i,"sec2h"); $secs['sec2t'] = mysql_result($result,$i,"sec2t"); $secs['sec3h'] = mysql_result($result,$i,"sec3h"); $secs['sec3t'] = mysql_result($result,$i,"sec3t"); $secs['sec4h'] = mysql_result($result,$i,"sec4h"); $secs['sec4t'] = mysql_result($result,$i,"sec4t"); foreach($secs as $k => $v){ $ex = explode(' ', $v); foreach($ex as $key => $value){ if(ereg("^[^@]{1,64}@[^@]{1,255}$", $value)){ $value = str_replace($value, '<a href="mailto:' . $value . '">' . $value . '</a>', $value); }elseif(ereg('^((http|https)://)?(((www\.)?[^ ]+\.([com|org|net|edu|gov|us]|[co\.uk]))|([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+))([^ ]+)?$', $value)){ if(preg_match('(http|https)', $value)){ $value = str_replace($value, '<a href="' . $value . '" target="_blank">' . $value . '</a>', $value); }else{ $value = str_replace($value, '<a href="http://' . $value . '" target="_blank">' . $value . '</a>', $value); } } $text[] = $value; } $v = implode(" ", $text); print "<tr>"; print "<td width='450' colspan='2' align='left'><hr></td>"; print "</tr>"; print "<tr>"; print "<td width='682' align='left' class='table-header'>$title<br><br></td><td width='120' align='left'>$findate</td>"; print "</tr>"; print "<tr>"; print "<td colspan='2' align='left'><b>$sec1h</b><br>$sec1t<br><br></td>"; print "</tr>"; print "<tr>"; print "<td colspan='2' align='left'><b>$sec2h</b><br>$sec2t<br><br></td>"; print "</tr>"; print "<tr>"; print "<td colspan='2' align='left'><b>$sec3h</b><br>$sec3t<br><br></td>"; print "</tr>"; print "<tr>"; print "<td colspan='2' align='left'><b>$sec4h</b><br>$sec4t<br><br></td>"; print "</tr>"; } $i++; } include 'closedb.php'; ?> EDIT: that code is under the presumption that $id = mysql_result($result,$i,"id"); $findate = mysql_result($result,$i,"findate"); $title = mysql_result($result,$i,"title"); aren't meant to be checked... Link to comment https://forums.phpfreaks.com/topic/44542-email-or-url-link/#findComment-278572 Share on other sites More sharing options...
NoDoze Posted June 20, 2007 Author Share Posted June 20, 2007 Opps...when I change the code to what you have above, the headers of the sections get looped... And what do you mean by: EDIT: that code is under the presumption that Code: $id = mysql_result($result,$i,"id"); $findate = mysql_result($result,$i,"findate"); $title = mysql_result($result,$i,"title");aren't meant to be checked... What "checked" are you talking about? btw, fyi, this is the only php on this page. Link to comment https://forums.phpfreaks.com/topic/44542-email-or-url-link/#findComment-278768 Share on other sites More sharing options...
Dragen Posted June 20, 2007 Share Posted June 20, 2007 Opps...when I change the code to what you have above, the headers of the sections get looped... okay.. try this: <?php include 'config.php'; include 'opendb.php'; $query = "SELECT * ,DATE_FORMAT(indate, '%b %d %Y') AS findate FROM jobs ORDER BY indate DESC"; if(isset($_GET['sortby'])){ $query .= " ORDER BY '" . $_GET['sortby'] . "'"; } $result = mysql_query($query); mysql_close(); $num = mysql_numrows($result); $i = 0; while ($i < $num) { print "<tr>"; print "<td width='450' colspan='2' align='left'><hr></td>"; print "</tr>"; print "<tr>"; print "<td width='682' align='left' class='table-header'>$title<br><br></td><td width='120' align='left'>$findate</td>"; print "</tr>"; print "<tr>"; $id = mysql_result($result,$i,"id"); $findate = mysql_result($result,$i,"findate"); $title = mysql_result($result,$i,"title"); $secs['sec1h'] = mysql_result($result,$i,"sec1h"); $secs['sec1t'] = mysql_result($result,$i,"sec1t"); $secs['sec2h'] = mysql_result($result,$i,"sec2h"); $secs['sec2t'] = mysql_result($result,$i,"sec2t"); $secs['sec3h'] = mysql_result($result,$i,"sec3h"); $secs['sec3t'] = mysql_result($result,$i,"sec3t"); $secs['sec4h'] = mysql_result($result,$i,"sec4h"); $secs['sec4t'] = mysql_result($result,$i,"sec4t"); foreach($secs as $k => $v){ $ex = explode(' ', $v); foreach($ex as $key => $value){ if(ereg("^[^@]{1,64}@[^@]{1,255}$", $value)){ $value = str_replace($value, '<a href="mailto:' . $value . '">' . $value . '</a>', $value); }elseif(ereg('^((http|https)://)?(((www\.)?[^ ]+\.([com|org|net|edu|gov|us]|[co\.uk]))|([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+))([^ ]+)?$', $value)){ if(preg_match('(http|https)', $value)){ $value = str_replace($value, '<a href="' . $value . '" target="_blank">' . $value . '</a>', $value); }else{ $value = str_replace($value, '<a href="http://' . $value . '" target="_blank">' . $value . '</a>', $value); } } $text[] = $value; } $v = implode(" ", $text); print "<td colspan='2' align='left'><b>$sec1h</b><br>$sec1t<br><br></td>"; print "</tr>"; print "<tr>"; print "<td colspan='2' align='left'><b>$sec2h</b><br>$sec2t<br><br></td>"; print "</tr>"; print "<tr>"; print "<td colspan='2' align='left'><b>$sec3h</b><br>$sec3t<br><br></td>"; print "</tr>"; print "<tr>"; print "<td colspan='2' align='left'><b>$sec4h</b><br>$sec4t<br><br></td>"; print "</tr>"; } $i++; } include 'closedb.php'; ?> And what do you mean by: EDIT: that code is under the presumption that Code: $id = mysql_result($result,$i,"id"); $findate = mysql_result($result,$i,"findate"); $title = mysql_result($result,$i,"title");aren't meant to be checked... What "checked" are you talking about? btw, fyi, this is the only php on this page. I meant that I didn't think you wanted them verified through the link and email check... Link to comment https://forums.phpfreaks.com/topic/44542-email-or-url-link/#findComment-278812 Share on other sites More sharing options...
NoDoze Posted June 21, 2007 Author Share Posted June 21, 2007 didn't work. didn't show anything. I don't get it cause the code looks solid... Thanks for the help. Link to comment https://forums.phpfreaks.com/topic/44542-email-or-url-link/#findComment-279458 Share on other sites More sharing options...
Dragen Posted June 22, 2007 Share Posted June 22, 2007 it's probably a problem with your sql query then. You've not no error checking for it.. have a go at with this.. I've added in error checks to the code: <?php include 'config.php'; include 'opendb.php'; $query = "SELECT * ,DATE_FORMAT(indate, '%b %d %Y') AS findate FROM jobs ORDER BY indate DESC"; if(isset($_GET['sortby'])){ $query .= " ORDER BY '" . $_GET['sortby'] . "'"; } if($result = mysql_query($query)){ if(mysql_num_rows($result) > 0){ $i = 0; while($row = mysql_fetch_assoc($result)){ print "<tr>"; print "<td width='450' colspan='2' align='left'><hr></td>"; print "</tr>"; print "<tr>"; print "<td width='682' align='left' class='table-header'>$title<br><br></td><td width='120' align='left'>$findate</td>"; print "</tr>"; print "<tr>"; $id = mysql_result($result,$i,"id"); $findate = mysql_result($result,$i,"findate"); $title = mysql_result($result,$i,"title"); $secs['sec1h'] = mysql_result($result,$i,"sec1h"); $secs['sec1t'] = mysql_result($result,$i,"sec1t"); $secs['sec2h'] = mysql_result($result,$i,"sec2h"); $secs['sec2t'] = mysql_result($result,$i,"sec2t"); $secs['sec3h'] = mysql_result($result,$i,"sec3h"); $secs['sec3t'] = mysql_result($result,$i,"sec3t"); $secs['sec4h'] = mysql_result($result,$i,"sec4h"); $secs['sec4t'] = mysql_result($result,$i,"sec4t"); foreach($secs as $k => $v){ $ex = explode(' ', $v); foreach($ex as $key => $value){ if(ereg("^[^@]{1,64}@[^@]{1,255}$", $value)){ $value = str_replace($value, '<a href="mailto:' . $value . '">' . $value . '</a>', $value); }elseif(ereg('^((http|https)://)?(((www\.)?[^ ]+\.([com|org|net|edu|gov|us]|[co\.uk]))|([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+))([^ ]+)?$', $value)){ if(preg_match('(http|https)', $value)){ $value = str_replace($value, '<a href="' . $value . '" target="_blank">' . $value . '</a>', $value); }else{ $value = str_replace($value, '<a href="http://' . $value . '" target="_blank">' . $value . '</a>', $value); } } $text[] = $value; } $v = implode(" ", $text); print "<td colspan='2' align='left'><b>$sec1h</b><br>$sec1t<br><br></td>"; print "</tr>"; print "<tr>"; print "<td colspan='2' align='left'><b>$sec2h</b><br>$sec2t<br><br></td>"; print "</tr>"; print "<tr>"; print "<td colspan='2' align='left'><b>$sec3h</b><br>$sec3t<br><br></td>"; print "</tr>"; print "<tr>"; print "<td colspan='2' align='left'><b>$sec4h</b><br>$sec4t<br><br></td>"; print "</tr>"; } $i++; } }else{ return 'Sorry, but no results were found'; } }else{ return 'Query failed<br />' . mysql_error() . ''; } include 'closedb.php'; ?> Link to comment https://forums.phpfreaks.com/topic/44542-email-or-url-link/#findComment-280071 Share on other sites More sharing options...
NoDoze Posted June 22, 2007 Author Share Posted June 22, 2007 Sorry to report... no go. It's definately the code though... It shows the html portion of the page, but the php stuff is blank...as it did previously. thanks for the help...this is definately over my head...the code looks good to me, I can't understand why it wouldn't work... Link to comment https://forums.phpfreaks.com/topic/44542-email-or-url-link/#findComment-280210 Share on other sites More sharing options...
Dragen Posted June 22, 2007 Share Posted June 22, 2007 it's a bit long winded, but it's one in the morning here and I can think of anything better at the moment.. This may not work either, but I'm too tired to check through it properly.. <?php include 'config.php'; include 'opendb.php'; $query = "SELECT * ,DATE_FORMAT(indate, '%b %d %Y') AS findate FROM jobs ORDER BY indate DESC"; if(isset($_GET['sortby'])){ $query .= " ORDER BY '" . $_GET['sortby'] . "'"; } if($result = mysql_query($query)){ if(mysql_num_rows($result) > 0){ $i = 0; while($row = mysql_fetch_assoc($result)){ print "<tr>"; print "<td width='450' colspan='2' align='left'><hr></td>"; print "</tr>"; print "<tr>"; print "<td width='682' align='left' class='table-header'>$title<br><br></td><td width='120' align='left'>$findate</td>"; print "</tr>"; $id = mysql_result($result,$i,"id"); $findate = mysql_result($result,$i,"findate"); $title = mysql_result($result,$i,"title"); $secsh['sec1h'] = mysql_result($result,$i,"sec1h"); $secsh['sec2h'] = mysql_result($result,$i,"sec2h"); $secsh['sec3h'] = mysql_result($result,$i,"sec3h"); $secsh['sec4h'] = mysql_result($result,$i,"sec4h"); $secst['sec1t'] = mysql_result($result,$i,"sec1t"); $secst['sec2t'] = mysql_result($result,$i,"sec2t"); $secst['sec3t'] = mysql_result($result,$i,"sec3t"); $secst['sec4t'] = mysql_result($result,$i,"sec4t"); foreach($secsh as $k => $v){ $ex = explode(' ', $v); foreach($ex as $key => $value){ if(ereg("^[^@]{1,64}@[^@]{1,255}$", $value)){ $value = str_replace($value, '<a href="mailto:' . $value . '">' . $value . '</a>', $value); }elseif(ereg('^((http|https)://)?(((www\.)?[^ ]+\.([com|org|net|edu|gov|us]|[co\.uk]))|([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+))([^ ]+)?$', $value)){ if(preg_match('(http|https)', $value)){ $value = str_replace($value, '<a href="' . $value . '" target="_blank">' . $value . '</a>', $value); }else{ $value = str_replace($value, '<a href="http://' . $value . '" target="_blank">' . $value . '</a>', $value); } } $text[] = $value; } $v['secsh'][] = implode(" ", $text); } foreach($secst as $k => $v){ $ex = explode(' ', $v); foreach($ex as $key => $value){ if(ereg("^[^@]{1,64}@[^@]{1,255}$", $value)){ $value = str_replace($value, '<a href="mailto:' . $value . '">' . $value . '</a>', $value); }elseif(ereg('^((http|https)://)?(((www\.)?[^ ]+\.([com|org|net|edu|gov|us]|[co\.uk]))|([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+))([^ ]+)?$', $value)){ if(preg_match('(http|https)', $value)){ $value = str_replace($value, '<a href="' . $value . '" target="_blank">' . $value . '</a>', $value); }else{ $value = str_replace($value, '<a href="http://' . $value . '" target="_blank">' . $value . '</a>', $value); } } $text[] = $value; } $v['secst'][] = implode(" ", $text); } $a = 0; foreach($v['secsh'] as $key => $value){ print "<tr>"; print "<td colspan='2' align='left'><b>" . $value . "</b><br>" . $vsecst[$a] . "<br><br></td>"; print "</tr>"; $a++; } $i++; } }else{ return 'Sorry, but no results were found'; } }else{ return 'Query failed<br />' . mysql_error() . ''; } include 'closedb.php'; ?> if you still get nothing, check the html source to see if the print "<tr>"; print "<td colspan='2' align='left'><b>" . $value . "</b><br>" . $vsecst[$a] . "<br><br></td>"; print "</tr>"; section is actually being echoed, but for some reason the variables don't have values, or something. Link to comment https://forums.phpfreaks.com/topic/44542-email-or-url-link/#findComment-280558 Share on other sites More sharing options...
NoDoze Posted June 25, 2007 Author Share Posted June 25, 2007 No go again...but got wierd results... nothing showed except the headers of each section...8 times in a row... ...so...section 1 header listed 8 times in a row, then section 2 header showed 8 times in a row, ect, ect... Link to comment https://forums.phpfreaks.com/topic/44542-email-or-url-link/#findComment-282222 Share on other sites More sharing options...
Dragen Posted June 25, 2007 Share Posted June 25, 2007 okay... what do you get from this? <?php include 'config.php'; include 'opendb.php'; $query = "SELECT * ,DATE_FORMAT(indate, '%b %d %Y') AS findate FROM jobs ORDER BY indate DESC"; if(isset($_GET['sortby'])){ $query .= " ORDER BY '" . $_GET['sortby'] . "'"; } if($result = mysql_query($query)){ if(mysql_num_rows($result) > 0){ $i = 0; print "<tr>"; print "<td width='450' colspan='2' align='left'><hr></td>"; print "</tr>"; print "<tr>"; print "<td width='682' align='left' class='table-header'>$title<br><br></td><td width='120' align='left'>$findate</td>"; print "</tr>"; while($row = mysql_fetch_assoc($result)){ $id = mysql_result($result,$i,"id"); $findate = mysql_result($result,$i,"findate"); $title = mysql_result($result,$i,"title"); $secsh['sec1h'] = mysql_result($result,$i,"sec1h"); $secsh['sec2h'] = mysql_result($result,$i,"sec2h"); $secsh['sec3h'] = mysql_result($result,$i,"sec3h"); $secsh['sec4h'] = mysql_result($result,$i,"sec4h"); $secst['sec1t'] = mysql_result($result,$i,"sec1t"); $secst['sec2t'] = mysql_result($result,$i,"sec2t"); $secst['sec3t'] = mysql_result($result,$i,"sec3t"); $secst['sec4t'] = mysql_result($result,$i,"sec4t"); foreach($secsh as $k => $v){ $ex = explode(' ', $v); foreach($ex as $key => $value){ if(ereg("^[^@]{1,64}@[^@]{1,255}$", $value)){ $value = str_replace($value, '<a href="mailto:' . $value . '">' . $value . '</a>', $value); }elseif(ereg('^((http|https)://)?(((www\.)?[^ ]+\.([com|org|net|edu|gov|us]|[co\.uk]))|([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+))([^ ]+)?$', $value)){ if(preg_match('(http|https)', $value)){ $value = str_replace($value, '<a href="' . $value . '" target="_blank">' . $value . '</a>', $value); }else{ $value = str_replace($value, '<a href="http://' . $value . '" target="_blank">' . $value . '</a>', $value); } } $text[] = $value; } $v['secsh'][] = implode(" ", $text); } foreach($secst as $k => $v){ $ex = explode(' ', $v); foreach($ex as $key => $value){ if(ereg("^[^@]{1,64}@[^@]{1,255}$", $value)){ $value = str_replace($value, '<a href="mailto:' . $value . '">' . $value . '</a>', $value); }elseif(ereg('^((http|https)://)?(((www\.)?[^ ]+\.([com|org|net|edu|gov|us]|[co\.uk]))|([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+))([^ ]+)?$', $value)){ if(preg_match('(http|https)', $value)){ $value = str_replace($value, '<a href="' . $value . '" target="_blank">' . $value . '</a>', $value); }else{ $value = str_replace($value, '<a href="http://' . $value . '" target="_blank">' . $value . '</a>', $value); } } $text[] = $value; } $v['secst'][] = implode(" ", $text); } $a = 0; foreach($v['secsh'] as $key => $value){ print "<tr>"; //print "<td colspan='2' align='left'><b>" . $value . "</b><br>" . $vsecst[$a] . "<br><br></td>"; print "<td colspan='2' align='left'><b>I am a variable.. can you see me?</b></td>"; print "</tr>"; $a++; } $i++; } }else{ return 'Sorry, but no results were found'; } }else{ return 'Query failed<br />' . mysql_error() . ''; } include 'closedb.php'; ?> Link to comment https://forums.phpfreaks.com/topic/44542-email-or-url-link/#findComment-282233 Share on other sites More sharing options...
NoDoze Posted June 26, 2007 Author Share Posted June 26, 2007 heh...worst off..."Page Cannot Be Displayed"....sorry... Link to comment https://forums.phpfreaks.com/topic/44542-email-or-url-link/#findComment-283493 Share on other sites More sharing options...
Dragen Posted June 27, 2007 Share Posted June 27, 2007 page cannot be displayed? What else does it say? any error message like mysql error etc? Link to comment https://forums.phpfreaks.com/topic/44542-email-or-url-link/#findComment-283928 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.