You are missing our premiere tool bar navigation system! Register and use it for FREE!

NukeCops  
•  Home •  Downloads •  Gallery •  Your Account •  Forums • 
Readme First
- Readme First! -

Read and follow the rules, otherwise your posts will be closed
Modules
· Home
· FAQ
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· PHP-Nuke HOWTO
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 135 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
Nuke Cops :: View topic - How to make url and email fields from a database clickable.. [ ]
 Forum FAQ  •  Search  •   •  Memberlist  •  Usergroups   •  Register  •  Profile •    •  Log in to check your private messages  •  Log in

 
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
Author Message
Tjendol
Sergeant
Sergeant


Joined: Dec 15, 2003
Posts: 77


PostPosted: Fri Dec 19, 2003 3:27 am Reply with quoteBack to top

Hi,

I've made a simple page in wich a title, url, name and e-mail can be sumbitted with a form. The values are stored in a database.

I've managed to convert a found e-mail address into a clickable link.
The problem is, this address is placed on top of the table, and I want it in the e-mail column.

can anyone help me with this?

This is the code that needs to be altered

Code:
<?php session_start(); ?>
<?php /* no security */ ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php include ("db.php") ?>
<?php include ("function.php") ?>
<?php
$displayRecs = 20;
$recRange = 10;

// Get table name
$tablename = "`titles`";
$dbwhere = "";
$a_search = "";
$b_search = "";
?>

<?php
// Get search criteria for basic search
$pSearch = @$HTTP_GET_VARS["psearch"];
if ($pSearch != "")
{
   $pSearch = (!get_magic_quotes_gpc()) ? addslashes($pSearch) : $pSearch;
   $b_search .= "`title` LIKE '%".$pSearch."%' OR ";
   $b_search .= "`url` LIKE '%".$pSearch."%' OR ";
   $b_search .= "`name_author` LIKE '%".$pSearch."%' OR ";
   $b_search .= "`e-mail` LIKE '%".$pSearch."%' OR ";
}
if (strlen($b_search) > 4)
{
   $b_search = substr($b_search, 0, strlen($b_search)-4);
   $b_search = "(".$b_search.")";
}
?>
<?php
//Build search criteria
if ($a_search != "")
{
   $dbwhere .= $a_search; //advance search
} elseif ($b_search!="") {
   $dbwhere .= $b_search; //basic search
}

//Save search criteria
if ($dbwhere != "")
{
      $HTTP_SESSION_VARS["tablename"] = $tablename;
    $HTTP_SESSION_VARS["dbwhere"] = $dbwhere;
   //reset start record counter
    $startRec = 1;
    $HTTP_SESSION_VARS["titles_REC"] = $startRec;
} else {
    if ($tablename == @$HTTP_SESSION_VARS["tablename"])
    {
      $dbwhere = $HTTP_SESSION_VARS["dbwhere"];
    } else {
      //reset search criteria
         $dbwhere = "";
         $HTTP_SESSION_VARS["dbwhere"] = $dbwhere;
    }
}

//Get clear search cmd
$cmd = @$HTTP_GET_VARS["cmd"];
if (strtoupper($cmd)=="RESET")
{
   //reset search criteria
    $dbwhere = "";
    $HTTP_SESSION_VARS["dbwhere"] = $dbwhere;
}
?>
<?php
// Load Default Order
$DefaultOrder = "";
$DefaultOrderType = "";

// Check for an Order parameter
$OrderBy = @$HTTP_GET_VARS["order"];

if ($OrderBy != "")
{   
   // Check if an ASC/DESC toggle is required
   if ($HTTP_SESSION_VARS["titles_OB"] == $OrderBy)
   {   
      if ($HTTP_SESSION_VARS["titles_OT"] == "ASC")
      {      
         $HTTP_SESSION_VARS["titles_OT"] = "DESC";
      } else {
         $HTTP_SESSION_VARS["titles_OT"] = "ASC";
      }
   } else {
      $HTTP_SESSION_VARS["titles_OT"] = "ASC";
   }
   $HTTP_SESSION_VARS["titles_OB"] = $OrderBy;
   $HTTP_SESSION_VARS["titles_REC"] = 1;
} else {   
   $OrderBy = @$HTTP_SESSION_VARS["titles_OB"];
   if ($OrderBy == "")
   {
      $OrderBy = $DefaultOrder;
      $HTTP_SESSION_VARS["titles_OB"] = $OrderBy;
      $HTTP_SESSION_VARS["titles_OT"] = $DefaultOrderType;
   }
}

// Check for a START parameter
$startRec = @$HTTP_GET_VARS["start"];

if ($startRec != "")
{
   $HTTP_SESSION_VARS["titles_REC"] = $startRec;
} else {
   $startRec = @$HTTP_SESSION_VARS["titles_REC"];
   if ($startRec == "")
   {
      //reset start record counter
        $startRec = 1;
        $HTTP_SESSION_VARS["titles_REC"] = $startRec;
   }
}

//Set the last record to display
$stopRec = $startRec + $displayRecs - 1;

// Open Connection to the database
$conn = mysql_connect(HOST, USER, PASS);
mysql_select_db(DB);

// Build Query
$strsql = "SELECT * FROM `titles`";

if ($dbwhere != "")
{
   $strsql .= " WHERE ".$dbwhere;
}

if ($OrderBy != "")
{
   $strsql .= " ORDER BY `".$OrderBy."` ".@$HTTP_SESSION_VARS["titles_OT"];
}

$rs = mysql_query($strsql, $conn) or die(mysql_error());

$totalRecs = mysql_num_rows($rs);
?>
<?php include ("header.php") ?>
<p><font size="-1">TABLE: titles</font></p>

<form action="titleslist.php">
<table border="0" cellspacing="1" cellpadding="4">
   <tr>      
      <td><font size="-1"><b>Quick Search (*)</b></font></td>
      <td>
      <input type="Text" name="psearch" size=10>
      <input type="Submit" name="Submit" value="GO!">
      </td>
      <td><a href="titleslist.php?cmd=reset"><font size="-1">Show All</font></a></td>
   </tr>
</table>
</form>

<table border="0" cellspacing="0" cellpadding="0">
   <tr>
      <td height="0" align="left"><a href="titlesadd.php"><font size="-1">Submit a title-Rip link</font></a></td>
   </tr>
</table>
<p>

<form>
  <table width="90%" border="1" cellpadding="5" cellspacing="1" bordercolor="#000000" bgcolor="#CCCCCC">
    <tr background="../themes/fisubsilversh/forums/images/cellpic1.gif">
      <td> <a href="titleslist.php?order=<?php echo urlencode("title"); ?>"><font color="#FFFFFF"><font color="#000000" size="-1">Movie
        title &nbsp;(*)</font></font></a> </td>
      <td> <a href="titleslist.php?order=<?php echo urlencode("url"); ?>"><font color="#FFFFFF"><font color="#000000" size="-1">Download
        url&nbsp;(*)</font></font></a> </td>
      <td> <a href="titleslist.php?order=<?php echo urlencode("name_author"); ?>"><font color="#FFFFFF"><font color="#000000" size="-1">Name
        author&nbsp;(*)</font></font></a> </td>
      <td> <a href="titleslist.php?order=<?php echo urlencode("e-mail"); ?>"><font color="#FFFFFF"><font color="#000000" size="-1">E
        mail&nbsp;(*)</font></font></a> </td>
      <td><font color="#000000">&nbsp;</font></td>
    </tr>
    <?php
$recCount = $startRec - 1;
@mysql_data_seek($rs, $recCount);
while (($row = mysql_fetch_assoc($rs)) && ($recCount < $stopRec))
{
   $recCount++;
   if (intval($recCount) >= intval($startRec))
    {
      //set row color
      $bgcolor="#FFFFFF";
?>
    <?php
      // Display alternate color for rows
      if ($recCount % 2 != 0)
      {
         $bgcolor = "#F5F5F5";
      }
?>
    <?php
$x_title = $row["title"];
$x_url = $row["url"];
$x_name_author = $row["name_author"];
$x_e2Dmail = $row["e-mail"];
$szEmail = $myrow["league_email"] ;
$x_e2Dmail = preg_replace(Array("/\@/", "/\./"), Array("@", "."), $x_e2Dmail);
print "Email: <a href=\"mailto:".$x_e2Dmail." class=\"data\">".$x_e2Dmail."</a><br />\n";
?>




    <tr bgcolor="#FFFFFF">
      <td><font size="-1"> <?php echo $x_title ?>&nbsp; </font></td>
      <td><font size="-1"> <?php echo $x_url ?>&nbsp; </font></td>
      <td><font size="-1"> <?php echo $x_name_author ?>&nbsp; </font></td>
      <td><font size="-1"> <?php echo $x_e2Dmail ?></font></td>
      <td><a href="<?php
if ($row["url"] != NULL)
{ echo "titlesview.php?key=".urlencode($row["url"]); }
else
{ echo "javascript:alert('Invalid Record! Key is null.');"; }
?>"><font size="-1">View</font></a></td>
    </tr>
    <?php
   }
}

mysql_free_result($rs);
mysql_close($conn);
?>
  </table>
</form>
<?php
if ($totalRecs > 0)
{
   // Find out if there should be Backward or Forward Buttons on the table.
   if ($startRec == 1)
   {
       $isPrev = false;
   } else   {   
      $isPrev = true;
      $PrevStart = $startRec - $displayRecs;
      if ($PrevStart < 1)
      {
         $PrevStart = 1;
      }
?>
   <hr size="1" noshade>
   <strong><a href="titleslist.php?start=<?php echo $PrevStart; ?>"><font size="-1">[&lt;&lt;&nbsp;Prev]</font></a></strong>
<?php
   }

   // Display Page numbers
    if ($isPrev||(!($totalRecs == 0)))
    {
         if (!$isPrev)
         {
?>
   <hr size="1" noshade>
<?php
      }

      $x = 1;
         $y = 1;

         $dx1 = intval(($startRec - 1)/($displayRecs*$recRange))*$displayRecs*$recRange + 1;
        $dy1 = intval(($startRec - 1)/($displayRecs*$recRange))*$recRange + 1;
         if (($dx1 + $displayRecs*$recRange - 1) > $totalRecs)
      {      
         $dx2 = intval($totalRecs/$displayRecs)*$displayRecs + 1;
         $dy2 = intval($totalRecs/$displayRecs) + 1;
      } else {
         $dx2 = $dx1 + $displayRecs*$recRange - 1;
           $dy2 = $dy1 + $recRange - 1;
      }


      while ($x <= $totalRecs)
         {
         if (($x >= $dx1)&&($x <= $dx2))
           {
                if (intval($startRec) == intval($x))
                {
?>
   <strong><font size="-1"><?php echo $y; ?></font></strong>
<?php
            } else {
?>
   <strong><a href="titleslist.php?start=<?php echo $x; ?>"><font size="-1"><?php echo $y; ?></font></a></strong>
<?php
            }
               $x = $x + $displayRecs;
                $y = $y + 1;
           } elseif (($x >= ($dx1 - $displayRecs*$recRange))&&($x <= ($dx2 + $displayRecs*$recRange)))
           {

                if ($x + $recRange*$displayRecs < $totalRecs)
                {
?>
      <strong><a href="titleslist.php?start=<?php echo $x; ?>"><font size="-1"><?php echo $y; ?>-<?php echo $y + $recRange - 1; ?></font></a></strong>
<?php
            } else {
                  $ny = intval(($totalRecs - 1)/$displayRecs) + 1;
               if ($ny == $y)
                  {
   ?>
      <strong><a href="titleslist.php?start=<?php echo $x; ?>"><font size="-1"><?php echo $y; ?></font></a></strong>
   <?php
               } else {
   ?>
      <strong><a href="titleslist.php?start=<?php echo $x; ?>"><font size="-1"><?php echo $y; ?>-<?php echo $ny; ?></font></a></strong>
   <?php
               }
            }   
                $x = $x + $recRange*$displayRecs;
                $y = $y + $recRange;
           } else {
                $x = $x + $recRange*$displayRecs;
                $y = $y + $recRange;
           }
      }
   }

   // Next link
    if ($totalRecs >= $startRec + $displayRecs)
    {
      $NextStart = $startRec + $displayRecs;
      $isMore = true;
 ?>
   <strong><a href="titleslist.php?start=<?php echo $NextStart; ?>"><font size="-1">[Next&nbsp;&gt;&gt;]</font></a></strong>
<?php
   } else {
      $isMore=false;
    }
 ?>
   <hr size="1" noshade>
<?php
   if ($stopRec > $recCount)
    {
    $stopRec = $recCount;
   }
 ?>
   <font size="-1">Records <?php echo $startRec; ?> to <?php echo $stopRec; ?> of <?php echo $totalRecs; ?></font>
<?php
} else {
?>
<br><br>
<font size="-1">No records found!</font>
<br><br>
<?php
}
?>
<?php include ("footer.php") ?>



Also, I would like an extra field that displays the time and date of an added item.

cheers,

Tjendol
Find all posts by TjendolView user's profileSend private message
Tjendol
Sergeant
Sergeant


Joined: Dec 15, 2003
Posts: 77


PostPosted: Fri Dec 19, 2003 5:38 am Reply with quoteBack to top

Ok, I got the e-mail code working.

Now I want the same thing for urls. Which parts do I have to change?
Find all posts by TjendolView user's profileSend private message
Zhen-Xjell
Nuke Cops Founder
Nuke Cops Founder


Joined: Nov 14, 2002
Posts: 5939


PostPosted: Fri Dec 19, 2003 6:23 am Reply with quoteBack to top

Do you have this available on the net to view?

_________________
Paul Laudanski, Microsoft MVP Windows-Security
CastleCops: [de] [en] [wiki]
Find all posts by Zhen-XjellView user's profileSend private messageSend e-mailVisit poster's website
Tjendol
Sergeant
Sergeant


Joined: Dec 15, 2003
Posts: 77


PostPosted: Fri Dec 19, 2003 6:53 am Reply with quoteBack to top

I sent you an e-mail with the link.
Find all posts by TjendolView user's profileSend private message
Tjendol
Sergeant
Sergeant


Joined: Dec 15, 2003
Posts: 77


PostPosted: Fri Dec 19, 2003 8:24 am Reply with quoteBack to top

I fixed it! thnx anyway
Find all posts by TjendolView user's profileSend private message
free69
Captain
Captain


Joined: Jan 18, 2003
Posts: 333

Location: Sniper Mobile Command

PostPosted: Fri Dec 26, 2003 4:11 am Reply with quoteBack to top

Dear Zhen-Xjell,

Regarding above scripts for gmtime(), I use similar one at the coppermine e-card, which sends very incorrect date(time is correct) to receiver, i.e. 2003-01-12, .... instead of actual date 2003-12-26,....

My PWS server is win2k/apache2/nuke7.0/coppermine1.2.1rc5.
Coppermine said that it should be my server problem.
And I checked my machine date is correct.
What should be wrong, Doctor.

_________________
Image
Find all posts by free69View user's profileSend private messageSend e-mailVisit poster's websiteICQ Number
Tjendol
Sergeant
Sergeant


Joined: Dec 15, 2003
Posts: 77


PostPosted: Sun Dec 28, 2003 7:40 am Reply with quoteBack to top

I still have a question too. It seems that only filling in "<a href"-works because that's just html.

But i want to covert http:// links into clickable links as well...what code do I need for this and where do I put it?
Find all posts by TjendolView user's profileSend private message
Tjendol
Sergeant
Sergeant


Joined: Dec 15, 2003
Posts: 77


PostPosted: Sun Dec 28, 2003 7:43 am Reply with quoteBack to top

Lol...i want the thing that happens to the http:// text in my post above on my website Smile
Find all posts by TjendolView user's profileSend private message
Display posts from previous:      
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2005 phpBB Group

Ported by Nuke Cops © 2003 www.nukecops.com
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::
Powered by TOGETHER TEAM srl ITALY http://www.togetherteam.it - DONDELEO E-COMMERCE http://www.DonDeLeo.com - TUTTISU E-COMMERCE http://www.tuttisu.it
Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.660 Seconds - 293 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::