Jump to content

runnerjp

Members
  • Posts

    2,214
  • Joined

  • Last visited

Posts posted by runnerjp

  1. Hey guys,

     

    If i add text like so into a reply on my forum

     

    hello

     

    there is a space above

     

    It shows it like this

     

    hello there is a space above

     

    The code here adds bbcode to the text

    ----------------------------------------------------

    <?php $message = new BBCode();
                                                    $message->selection = $_POST['yourpost'];
                                                    $message->parseCode();
                                                    $message->parseEmoticons();
                                                    $message = $message->parsed;
    echo $message;?>

    ----------------------------------------------------

     

    Is it the way im outputting the code?

    and below is the bbcode.

     

    <?php 
      
    class BBCode { 
         protected $bbcodes; // Store array of BBCodes 
         protected $vbbcodes; // Store array of Variable BBCodes 
         var $debug = ''; // Store any errors 
         var $selection = ''; // Store the selection to be parsed first 
         var $parsed = ''; // Store the parsed selection. 
         var $path2emoticon = 'http://www.runningprofiles.com/emoticons/'; // Set the path to the emoticon images. 
         var $imgext = '.gif'; // Set this to the ext of the images 
         public $emoticons =  
              array( '' => 'Roll Eyes', '' => 'Smiley', '' => 'Wink', '' => 'Cheesy', '' => 'Grin', '' => 'Angry', 
              '' => 'Sad', '' => 'Shocked', '' => 'Cool', '???' => 'Huh', '' => 'Tongue', ':-[' => 'Embarrassed',  
              ':-X' => 'Lips Sealed', ':-\\' => 'Undecided', '' => 'Kiss', ':*(' => 'Cry' );  
              // All emoticons. Spaces and caps will be removed for image names. 
          
         function parseCode($security=0) { // Security defaults to 0. Set to 1 for non-variable bbcodes only. 
              if(!$this->selection) { // Check if the user has set the selection. 
                   $this->debug .= "You must set a value for the selection before parsing! "; // Set the Debug variable if not. 
              }else{ 
                   if($this->parsed) { // Check if text has already been parsed. 
                        $this->debug .= "You must run the code parser before the emoticon parser! "; // Set the Debug variable if so. 
                   }else{ 
                        $selection = str_replace("\n", '', $this->selection); // Set selection variable for inside function only. 
                        $selection2 = htmlentities(str_replace("\n", '', $this->selection)); // Remove html entities for security. 
                        $this->selectCodes($security); // Select codes depending on security. 
                        #### Start [code] Section ### 
                        preg_match_all("/\[code\].+\[\/code\]/Ui", $selection2, $matches); // Check for [code] tags. Set the matches array. 
                        $i = 0; // Set the variable to the default of 0. 
                        while(isset($matches[0][$i])) { // Check for match from preg_match. 
                             $selection = str_ireplace(html_entity_decode($matches[0][$i]), "[code$i]", $selection); // Decode and replace for strip tags. 
                             $i++; // Add one to the variable to loop. 
                        } 
                        $selection = strip_tags($selection); // Strip tags from the selection. 
                        while($i>0) { // Reloop through matches. 
                             $i--; // Remove one from the variable to loop. 
                             $m = html_entity_decode($matches[0][$i]); // Decode the match for accurate removal. 
                             $m = str_ireplace("[code]", "", $m); // Remove [code] tag. 
                             $m = str_ireplace("

    ", "", $m); // Remove [/code] tag.

                            $m = highlight_string($m,true); // Highlight string and encode.

                            $selection = str_ireplace("

    [code$i]", "
    " . $m . "

    ", $selection); // Add highlighted code back with tags for later parsing.

                        }

                        #### End

     Section #### 
                        ### Start BBCode Section ### 
                        foreach ($this->bbcodes as $key => $value) { // Loop through bbcodes. 
                             $selection = str_ireplace($key, $value, $selection); // Replace the $key value(bbcode) with the $value value(html code). 
                        } 
                        #### End BBCode Section ### 
                        ### Start Var. BBCode Sec. ## 
                        if($security==0) { // Only loop through if security allows it. 
                             foreach ($this->vbbcodes as $key => $value) { // Loop through variable bbcodes. 
                                  unset($matches); // Unset matches set in earlier code. 
                                  $i = 0; // Set the variable to the default of 0. 
                                  preg_match_all($key, $selection, $matches); // Find all instances of the variable bbcode set them to matches. 
                                  // Preg Matching also stores the "variables" inside the matches var. with the matches. 
                                  while(isset($matches[0][$i])) { // Check if there are any instances. 
                                       $v = str_replace("*", $matches[1][$i], $value); // Replace the asterisk with the variable value. 
                                       if(isset($matches[2][$i])) { // Check for more than one variable. 
                                            $v = str_replace("~", $matches[2][$i], $v); // Replace the ~ with the second variable value. 
                                       } 
                                       $selection = str_replace($matches[0][$i], $v, $selection); // Replace the match with the accumulated variable. 
                                       $i++; // Add one to the variable to loop. 
                                  } 
                             } 
                        } 
                        ### End Var. BBCode Sec. ## 
                        $this->parsed = $selection; // Insert the accumulated parsed selection into the parsed variable as to keep selection original. 
                        unset($selection); // Remove all value from private variable selection. 
                   } 
              } 
         } 
          
          protected function selectCodes($security=0) { // Security defaults to 0. Set to 1 for non-variable bbcodes only. 
          switch ($security) { // Switch between 0 and 1. 
             default: // In the case of security being anything but one. Defaulting to zero. 
             case 0: // In the case of security being zero. 
                $this->bbcodes = 
                   array( "[i]" => "<i>", "[/i]" => "</i>",  "[b]" => "<b>", "[/b]" => "</b>", "[u]" => "<u>", "[/u]" => "</u>", "[s]" => "<del>", "[/s]" => "</del>", "[move]" => "<marquee>", "[/move]" => "</marquee>", 
                   "
    [center]" => "<center>", "[/center]
    " => "</center>", "[hr]" => "<hr />", "[table][tr][td]" => "<table>", "" => "</table>", "[table][tr][td]" => "<tr>", "[/td][/tr][/table]" => "</tr>", "[table][tr][td]" => "<td>", 
                   "[/td][/tr][/table]" => "</td>", "[sub]" => "<sub>", "[/sub]" => "</sub>", "[sup]" => "<sup>", "[/sup]" => "</sup>", "[tt]" => "<tt>", "[/tt]" => "</tt>", "[list]" => "<ul>", "[/list]" => "</ul>", "[list][*]" => "<li>", 
                   "[/list]" => "</li>", "[/size]" => "</font>", "[/face]" => "</font>", "[/color]" => "</font>", "[p]" => "<p>", "[/p]" => "</p>", 
                   "[/td][/tr][/table][code]" => "<p style=\"background: #BBBBBB; border: 1px solid #555555; padding: 6px;\"><span style=\"font: bold 10px Courier New;\">   CODE :</span><br/>",); 
                // BBCode array including their replacement. 
                $this->vbbcodes =  
                   array( "/\[size=(.+)\]/Ui" => "<font size=\"*\">", "/\[face=(.+)\]/U" => "<font face=\"*\">", "/\[color=(.+)\]/Ui" => "<font color=\"*\">", "/\[img\](.+)\[\/img\]/Ui" => "<img src=\"*\"  alt=\"img\"/>", 
                   "/\[email\](.+)\[\/email\]/Ui" => "<a href=\"mailto:*\">*</a>", "/\[url\](.+)\[\/url\]/Ui" => "<a href=\"http://*\"> * </a>", "/\[email=(.+)\](.+)\[\/email\]/Ui" => "<a href=\"mailto:*\"> ~ </a>", 
                   "/\[url=http://(.+)\](.+)\[\/url\]/Ui" => "<a href=\"*\">~</a>", "/\[quote](.+)\[\/quote\]/is" => "    
                               <div class=\"quote_header\">Quote:</div><div class=\"quote_body\">*</div>", "/\[quote=(.*)\](.*)\[\/quote\]/is" => 
    "<div><table style=\"BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; BORDER-LEFT: black 1px solid; WIDTH: 100%; BORDER-BOTTOM: black 1px solid; BORDER-COLLAPSE: collapse\"><tbody><tr><td style=\"BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; PADDING-LEFT: 3px; BACKGROUND: #99b3b4; BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid\">Quote by <a href=\"*\">*</a></td>        </tr>
    <tr><td style=\"BORDER-RIGHT: black 1px dotted; BORDER-TOP: black 1px dotted; PADDING-LEFT: 4px; BORDER-LEFT: black 1px dotted; BORDER-BOTTOM: black 1px dotted\">~ </td></tr></tbody></table></div>" );                     
                         
    
                // Variable BBCode array including their replacement and variable position(s). 
                break; 
             case 1: // In the case of security being one. 
                $this->bbcodes = 
                   array( "[i]" => "<i>", "[/i]" => "</i>", "[b]" => "<b>", "[/b]" => "</b>", "[u]" => "<u>", "[/u]" => "</u>", "[s]" => "<del>", "[/s]" => "</del>", "[move]" => "<marquee>", "[/move]" => "</marquee>", 
                   "
    [center]" => "<center>", "[/center]
    " => "</center>", "[hr]" => "<hr />", "[table][tr][td]" => "<table>", "" => "</table>", "[table][tr][td]" => "<tr>", "[/td][/tr][/table]" => "</tr>", "[table][tr][td]" => "<td>", 
                   "[/td][/tr][/table]" => "</td>", "[sub]" => "<sub>", "[/sub]" => "</sub>", "[sup]" => "<sup>", "[/sup]" => "</sup>", "[tt]" => "<tt>", "[/tt]" => "</tt>", "[list]" => "<ul>", "[/list]" => "</ul>", "[list][*]" => "<li>", 
                   "[/list]" => "</li>", "[/td][/tr][/table][code]" => "<p style=\"background: #BBBBBB; border: 1px solid #555555; padding: 6px;\"><span style=\"font: bold 10px Courier New;\">   CODE :</span><br/>", 
                   "

    " => "</p>" ,"

    " => "<p style=\"background: #BBBBBB; border: 1px solid #555555; padding: 6px;\"><span style=\"font: bold 10px Courier New;\">   CODE :</span><br/>", "

    " => "</p>");

                // BBCode array including their replacement.

                break; 

              }

        }

        function parseEmoticons($noBBCode=0) { // noBBCode variable defaults to 0. If set to one the parser will not parse be able to parse BBCode.

    if(!$this->selection) { // Check if the user has set the selection.

    $this->debug .= "You must set a value for the selection before parsing! "; // Set the Debug variable if not.

    }else{

    $error = 0; // Default to no errors.

    if($this->parsed) { // If something has already been parsed.

    $selection = str_replace("\n", '', $this->parsed); // Set the parsed value in order to not reset the already parsed selection.

    }elseif($noBBCode==1) { // If nothing has been parsed and the noBBCode variable has been set to one.

    $selection = str_replace("\n", '', $this->selection); // Set the selection value to variable selection.

    $error = 2; // Set the error variable to 2 so that it will not look for

     tags.
    }else{ // If all else fails.
    $this->debug .= "You must parse BBCode first or set the noBBCode variable to 1(setting this variable will not allow bbcode to be parsed)! "; // Set the Debug variable if it gets here.
    $error = 1; // Set the error variable so the parser doesn't run.
    }
    if($error==0 or $error==2) {
    if($error==0) { // Only search if there has been parsing.
    unset($matches);
    preg_match_all('/\<p style="background: #BBBBBB; border: 1px solid #555555; padding: 6px;"\>.+\<\/p\>/Uim', $selection, $matches); // Finds all code selections.
    $i = 0; // Set the variable to the default of 0.
    while(isset($matches[0][$i])) { // Check for match from preg_match.
    $selection = str_ireplace($matches[0][$i], "[code$i]", $selection); // Replace for non-emoticon section.
    $i++; // Add one to the variable to loop.
    }
    }
    foreach($this->emoticons as $key => $value) { // For each emoticon set the key and value.
    $v = str_replace(" ", "", $value); // Remove all spaces from value but not replacing the value variable.
    $v = "<img src=\"" . $this->path2emoticon . strtolower($v) . $this->imgext . "\" alt=\"$value\" />"; // Set the image replacement up.
    $selection = str_ireplace($key, $v, $selection); // Replace the key with the set up image replacement.
    }
    if($error==0) { // Only search if there has been parsing.
    while($i>0) { // Reloop through matches.
    $i--; // Remove one from the variable to loop.
    $selection = str_ireplace("[code$i]", $matches[0][$i], $selection); // Add the codes back for final display.
    }
    }
    $this->parsed = $selection; // Insert the accumulated parsed selection into the parsed variable as to keep selection original.
    unset($selection); // Remove all value from private variable selection.
    }
    }
    }
    }
    ?>
    

     

    Regards,

     

    Jarratt[/code]

  2. Hi,

     

    I need to create a PHP script that writes php errors (Warning notices etc.) to  MySQLdatabase. I know PHP has a built in error log function but im on a shared hosting site and cant chnage these types of files nor have any access ot them. Any ideas where I could start?

     

    I already have error reporting enabled at the start of my scripts,

     

    PHP Code:

    <?php
    ini_set('display_errors', 1);
    error_reporting(E_ALL & ~E_NOTICE);
    ?>

     

    The data i was thinkin of is:

    Date/time

    Page

    error

    Error line in code?

    Ip of user

    username

     

    then if an error is added to db send me an email so i know.

     

    Then rather then disply " there is an error in you syntax" ect it just prompts them to an error page of my own choosing.

     

    This way i wont show information which could lead to security holes!

     

     

    Thanks!

     

    Jarratt.

  3. Ok guys i have a page where im echoing a count number in a loop...

    $counter2= '1';

    $counter2++;

     

    How can i make it so on ach page of the pagination it adds 5 to the previous value??

     

    so on each page it will start with these numbers.

    page1  =  2, page 2  =  7 , page3  =  12, page4  =  17, page5  =  22, page6  =  27

     

    To get the page number i use this

     

    $pagenum                    =(is_numeric($pagenum) && $pagenum >= 1) ? (int)$pagenum : 1;

  4. Im tryign to number the posts on my forum. These numbers only refer to posts under a topic. Im not counting how many posts are under a topic but just giving them a number.

    At the moment i have this script in place:

     

    $counter2 = 1;
    $counter2++;
    

     

    The problem is when a go to page 2 it starts from 2 again.

     

    here is the full forum code so you can get an idea how it works

     

    <?php
    require_once '../settings.php';
    
    checkLogin('1 2');
    include "../info.php";    // sets username/id ect
    include "../getuser.php"; // records user view on page
    include "checkinfo.php";  //Your ip address is...;
    include "../BBClass.php"; //class for bbcode
    $gettopic3=mysql_fetch_assoc(mysql_query("SELECT * from forumtutorial_posts where postid='$forumpostid'"));
    include "forumnav.php";   // shows where you are on the forum
    $getuser = mysql_fetch_assoc(mysql_query("SELECT * from users where Username='$username'"));
    
    if ($notify == "yes")
        {
        $updateemail="DELETE FROM forum_email  WHERE topic_id='$forumpostid' AND user_id = '$id'";
        mysql_query($updateemail) or die(mysql_error());
        }
    
    //Here we count the number of results
    //Edit $data to be your query
    $data     =mysql_query("SELECT * from forumtutorial_posts where parentid='$forumpostid'") or die(mysql_error());
    $rows     =mysql_num_rows($data);
    
    //This is the number of results displayed per page
    $page_rows= 5;
    
    //This sets the range to display in our query
    if ($pagenum === "last")
        {
        $query ="Select COUNT(*) as C from forumtutorial_posts where parentid='$forumpostid'";
        $result=mysql_query($query);
        $data  =mysql_fetch_array($result);
    
        if ($data['C'] == 0)
            $pagenum=1;
        else
            $pagenum=ceil($data['C'] / $page_rows);
        }
    
    $pagenum                    =(is_numeric($pagenum) && $pagenum >= 1) ? (int)$pagenum : 1;
    $max                        ='limit ' . ($pagenum - 1) * $page_rows . ',' . $page_rows;
    //This is your query again, the same one... the only difference is we add $max into it
    $start = (($pagenum-1) * $page_rows)+1;
    
    {
        }
    ?>
    
    <table width = "80%" align="center">
        <tr>
            <td width = "36%" height = "21">
                <?php
                $getusersonline ="SELECT user_id,user FROM useronline 
       WHERE 
    (file LIKE 'http://www.runningprofiles.com/members/index.php?page=message&forum=$forum&id=$forumpostid' or
      file LIKE 'http://www.runningprofiles.com/members/index.php?page=message&forum=$forum&id=$forumpostid&forum=general' or
      file LIKE 'http://www.runningprofiles.com/members/index.php?page=message&forum=$forum&id=$forumpostid' or
      file LIKE 'http://www.runningprofiles.com/members/index.php?page=message&forum=$forum&id=$forumpostid&pagenum=$pagenum' or
        file LIKE 'http://www.runningprofiles.com/members/index.php?page=message&forum=$forum&id=$forumpostid&notify=yes' or
      file LIKE 'http://www.runningprofiles.com/members/index.php?page=message&forum=$forum&id=$forumpostid&pagenum=last' )
      
    
       
       AND
      timestamp > "
                    . (time() - 900); //grab from sql users on in last 15 minutes
                $getusersonline2=mysql_query($getusersonline) or die("Could not get users");
                $num            =mysql_num_rows($getusersonline2);
    
                echo " <b>Currently Viewing: </b>";
    
                $tmp=array();
    
                while ($getusersonline3=mysql_fetch_array($getusersonline2))
                    {
                    $tmp[]="<a href='$getusersonline3[user]'>$getusersonline3[user]</a>";
                    }
    
                echo implode(',', $tmp);
                ?>
            </td>
    
            <td width = "64%" align = "right" valign = "bottom">
                <div align = "right"><a href = "index.php?page=mainforums">
    
                    <img src = "/images/homeforum.gif" alt = "home" border = "0"/></a> <?php echo ' <a href="index.php?page=forum&forum=
    $forum">' ?><img src = "/images/backforum.gif" border = "0" alt = "back"/>
    
                    </a>
    
                    <?php
                    if ($gettopic3['forumlock'] == 0)
                        {
                    ?>
    
                    <?php
                        echo ' <a href="index.php?page=reply&id=$forumpostid&forum=$forum">'
                    ?>
    
                                        <img src = "/images/post_reply.gif" border = "0" alt = "reply"/>
    
                                        </a>
                </div>
    
                <?
                        }
                ?></td>
        </tr>
    
        <?php
        if ($pagenum == 1)
            {
        ?>
    </table>
    
    <table width = "90%" align="center" cellpadding = "0" cellspacing = "0" >
                <tr>
                    <td>
                        <table width = "100%" align = "center" cellpadding = "0" cellspacing = "0" class="loggedin">
                           <tr>
                        <td colspan="3" align="right" class = 'border'><table width="100%" style = "height:auto" >
                          <tr>
                            <td width="15%" align="left"><font size="2" color="white">  <a name="<?php echo $gettopic3['postid'] ?>" href = 'http://www.runningprofiles.com/members/index.php?page=message&forum=<?php echo $forum ?>&id=<?php echo $forumpostid ?>#<?php echo $gettopic3['postid'] ?>'><strong>#1</strong></a></font></td>
                            <td width="32%" align="left"></td>
                            <td width="33%" align="right"><font size="2" color="white">» Posted
                                <?
                                                $dbtime=$gettopic3['showtime'];
                                                $time  =date("F j Y, g:i a", $dbtime);
    
                                                $time  =date("F j, Y, g:i a", $dbtime);
                                                gettheTime($dbtime, $time);
                                            ?>
     «   </font></td>
                          </tr>
                        </table></td>
                        </tr>
    
                            <tr>
                                <td width = "20%" align = "center" valign = "middle" class = "forum_view_topic_header_2_b"
                                ><a href = '/members/<? echo
    $getreplies3['author']; ?>'>
    
                                    <span class = "style5"><? echo "<b>". $gettopic3['author']." </b>" ?></span></a> <?php
                                    $result = mysql_query(
                                                  "SELECT * FROM useronline WHERE(user='" . $gettopic3['author'] . "')");
    
                                    while ($row=mysql_fetch_array($result))
                                        {
                                        $last_active=time() - $row['timestamp'];
                                        }
    
                                    echo ($last_active < 300)
                                             ? '<img src="http://www.runningprofiles.com/images/useron.gif" width="12" height="11" alt= "usron" />'
                                             : '<img src="http://www.runningprofiles.com/images/useroff.gif" width="12" height="11"  alt= "usroff" />';
                                ?>
                                    <br />
                                  <?
                                    $query="SELECT * FROM users WHERE Username = '" . $gettopic3['author'] . "' LIMIT 1";
    
                                    if ($result=mysql_query($query))
                                        {
                                        if (mysql_num_rows($result))
                                            {
                                            $array  =mysql_fetch_assoc($result);
                                            $image  =$array['image'];
                                            $postnum=$array['post_count'];
    
                                            echo
                                                "<img src=\"http://www.runningprofiles.com/members/images/mini/$image\" border=\"1\" alt =\"mini\"  />";
                                ?> 
                                  <br />
    
                                        
                                            <span class = "style7"> Posts: <?php echo $postnum; ?> </span>
    
                                <?
                                            }
                                        }
                                ?>
                                </td>
    
                                <td width = "85%" colspan="2" style="background-color:white">
                                    <table width = "100%" border = "0" cellpadding = "5" cellspacing = "0">
                                        <tr>
                                                                                    <td width="96%" valign = "top"><span class="style1">
                                              <?php
                                                                $message =nl2br($gettopic3['post']);
                                                                $b =new BBCode();
                                                                $b->selection=nl2br($message);
                                                                $b->parseCode();
                                                                echo nl2br($b->parsed);
                                                            ?>
                                          </span></td>
    
                                        </tr>
    
                                        <tr>
                                            <td align = "left" valign = "top"></td>
                                        </tr>
    
                                        <tr>
                                            <td height = "27" colspan = "2" align = "right" >
                                               </td>
                                        </tr>
    
                                        <tr>
                                            <td height = "28" align = "right" valign = "top">
                                              <a href = "index.php?page=reply&forum=<?php echo $forum; ?>&id=<? echo
    $forumpostid ?>&pid=<? echo $gettopic3['postid']; ?>"><img src = "/images/quote.gif" border = "0" height="16" width="16" alt = "Quote"/></a>
                                              <?php
                                                $dbtime =$gettopic3['showtime'];
                                                $intTime=time();
                                                $intDiff=$intTime - $dbtime;
    
                                                if ($intDiff < 7200 && $gettopic3['author'] != $username)
                                                    {
                                            ?>
    <?php include "include/editmessage.php"; // shows where you are on the forum ?>
                                              <a href = "index.php?page=editmessage&forum=<?php echo $forum; ?>&id=<? echo
    $forumpostid ?>&pid=<? echo $gettopic3['postid']; ?>"><img src = "/images/edit.bmp" border = "0" alt = "Edit"/></a>
                                              <?php
                                                    }
                                            ?>
    <?php
    
    
                                                //Now increase it:
                                                $CONT_ID++;
    
                                                ;
                                            ?>
    
                                          
    
                                          </td>
    
                                            <td width = "4%" align = "right" valign = "bottom"> </td>
                                        </tr>
                              </table></td>
                          </tr>
                        </table></td>
                </tr>
            </table>
    
        <?php
            }
    
    
        $getreplies
                    =
            "Select * from forumtutorial_posts where parentid='$forumpostid' ORDER BY showtime $max"; //getting replies
    
        $getreplies2=mysql_query($getreplies) or die(mysql_error() . "Could not get replies");
    $counter2 = 1;
        while ($getreplies3=mysql_fetch_array($getreplies2))
            {
        ?><br />
    
            <table width = "90%" align="center" cellpadding = "0" cellspacing = "0" >
                <tr>
                    <td>
                        <table width = "100%" align = "center" cellpadding = "0" cellspacing = "0" class="loggedin">
                           <tr>
                        <td colspan="3" align="right" class = 'border'>  <table width="100%">
                          <tr>
                            <td width="15%" align="left"><font size="2" color="white">   
    
    <?php
    $counter2++;
    ?>
    
    <a name="<?php echo $getreplies3['postid'] ?>"> </a><a href ='http://www.runningprofiles.com/members/index.php?page=message&forum=<?php echo $forum ?>&id=<?php echo $forumpostid ?>#<?php echo $getreplies3['postid'] ?>'><strong>#<?php echo $counter2;?></strong></a></font></td>
                            <td width="32%" align="left"> </td>
                            <td width="33%" align="right"><font size="2" color="white">» Replied
                                <?
                                                $dbtime=$getreplies3['showtime'];
                                                $time  =date("F j Y, g:i a", $dbtime);
    
                                                $time  =date("F j, Y, g:i a", $dbtime);
                                                gettheTime($dbtime, $time);
                                            ?>
     «   </font></td>
                          </tr>
                        </table></td>
                        </tr>
    
                            <tr>
                                <td class = "forum_view_topic_header_2_b" width = "20%" align = "center" valign = "middle"
                                ><a href = '/members/<? echo
    $getreplies3['author']; ?>'>
    
                                    <span class = "style5"><? echo "<b>". $getreplies3['author']." </b>" ?></span></a>
                                  <?php
                                    $result = mysql_query(
                                                  "SELECT * FROM useronline WHERE(user='" . $getreplies3['author'] . "')");
    
                                    while ($row=mysql_fetch_array($result))
                                        {
                                        $last_active=time() - $row['timestamp'];
                                        }
    
                                    echo ($last_active < 300)
                                             ? '<img src="http://www.runningprofiles.com/images/useron.gif" width="12" height="11" alt= "usron" />'
                                             : '<img src="http://www.runningprofiles.com/images/useroff.gif" width="12" height="11"  alt= "usroff" />';
                                ?>
                                  <br />
                                  <?
                                    $query="SELECT * FROM users WHERE Username = '" . $getreplies3['author'] . "' LIMIT 1";
    
                                    if ($result=mysql_query($query))
                                        {
                                        if (mysql_num_rows($result))
                                            {
                                            $array  =mysql_fetch_assoc($result);
                                            $image  =$array['image'];
                                            $postnum=$array['post_count'];
    
                                            echo
                                                "<img src=\"http://www.runningprofiles.com/members/images/mini/$image\" border=\"1\" alt =\"mini\"  />";
                                ?>
                                  <br />
    
                                        
                                            <span class = "style7"> Posts: <?php echo $postnum; ?> </span>
    
                                <?
                                            }
                                        }
                                ?>
                                </td>
    
                                <td width = "85%" colspan="2" style="background-color:white">
                                  <table width = "100%" border = "0" cellpadding = "5" cellspacing = "0">
                                        <tr>
                                            
                                            <td width="96%" valign = "top">
                                              <?php     
                                                                $message =nl2br($getreplies3['post']);
                                                                $b =new BBCode();
                                                                $b->selection=nl2br($message);
                                                                $b->parseCode();
                                                                echo nl2br($b->parsed);
                                                            ?>
                                         </td>
    
                                        </tr>
    
                                        
                                        <tr>
                                            <td align = "left" valign = "top"></td>
                                        </tr>
    
                                        <tr>
                                            <td height = "27" colspan = "2" align = "right" >
                                             </td>
                                        </tr>
    
                                        <tr>
                                            <td height = "28" align = "right" valign = "top">
                                              <a href = "index.php?page=reply&forum=<?php echo $forum; ?>&id=<? echo
    $forumpostid ?>&pid=<? echo $getreplies3['postid']; ?>"><img src = "/images/quote.gif" border = "0" height="16" width="16" alt = "Quote"/></a>
                                              <?php
                                                $dbtime =$getreplies3['showtime'];
                                                $intTime=time();
                                                $intDiff=$intTime - $dbtime;
    
                                                if ($intDiff < 7200 && $getreply3['author'] != $username || $getuser = 'Admin')
                                                    {
                                          
                                                   
    
                                                       include 'editmessage.php';   
    
                                                //Now increase it:
                                                $CONT_ID++;
                                                  } 
                                                ;
                                            ?>
    
                                          
    
                                      </td>
    
                                            <td width = "4%" align = "right" valign = "bottom"> </td>
                                        </tr>
                                    </table></td>
                            </tr>
                        </table></td>
                </tr>
            </table>
    
    
    
        <?
            }
        ?>
    
        <?
        echo "<br /><center>";
    
        // Find out the total number of pages depending on the limit set
        $numofpages=$rows / $page_rows;
        $totalpages=ceil($numofpages);
        // Start links for pages
        $maxpage   =$totalpages == 0 ? 1 : $totalpages;                   // add this line
        echo "Page " . $pagenum . " of " . $maxpage . "</center>"; // change this
    
    
    
       // Sets link for previous 25 and return to page 1
        
         if ($pagenum != 1)
            {
            $pageprev=($pagenum - 1);
            echo "<center><a href=\"" . $_SERVER['PHP_SELF']
                     . "?page=message&forum=$forum&id=$forumpostid&pagenum=1\"><<</a>  ";
            echo "<a href=\"" . $_SERVER['PHP_SELF']
                     . "?page=message&forum=$forum&id=$forumpostid&pagenum=$pageprev\">PREV </a> ";
            }
        else
            {
            echo "<center>PREV ";
            }
       
    
        // Loop thru all the pages and echo out the links
        for ($i=1; $i <= $numofpages; $i++)
            {
            if ($i == $pagenum)
                {
                echo "[" . $i . "] ";
                }
            else
                {
                echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=message&forum=$forum&id=$forumpostid&pagenum=$i\">$i</a> ";
                }
            }
    
        // Check for straglers after the limit blocks
        if (($rows % $page_rows) != 0)
            {
            if ($i == $pagenum)
                {
                echo "[" . $i . "] ";
                }
            else
                {
                echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=message&forum=$forum&id=$forumpostid&pagenum=$i\">$i</a> ";
                }
            }
    
         // Print out the Next 25 and Goto Last page links
    if (($rows - ($page_rows * $pagenum)) > 0)
            {
            $pagenext=$pagenum++;
            echo "<a href=\"" . $_SERVER['PHP_SELF']
                     . "?page=message&forum=$forum&id=$forumpostid&pagenum=$pagenext\">NEXT </a>  ";
            echo "<a href=\"" . $_SERVER['PHP_SELF']
                     . "?page=message&forum=$forum&id=$forumpostid&pagenum=$totalpages\">>></a>  </center>";
            }
        else
            {
            echo("NEXT </center> <br />");
            }
        ?>
    

     

    As you can see if on pahe 1 it echos the topic starter.... anything more it doesnt and thats why i start it from number 2.

  5. the code below does not echo yes. If i add the date manually () if echos yes...  $date123 also echos out the date!

     

    where am i going wrong?

     

                 <?php 
    
                                     
    
                                                     $getthreads = 
                                    "Select * from daddiary  ORDER BY DATE (STR_TO_DATE( `date`, '%d/%m/%Y ' )) ASC"; 
    
                                $getthreads2=mysql_query($getthreads) or die("Could not get threads"); 
    
                                while ($getthreads3=mysql_fetch_array($getthreads2)) 
                                    { 
                          
                                    ?><tr <? if ( $getthreads3['date'] == date("d/m/Y") ) { echo 'bgcolor="#CAD9D9"'; }?> > 
    <td width="10%" height="39" align="center" valign="middle"><?php 
                                echo $getthreads3['date'];?> 
    
                                    </td>  
    <td width="15%" align="center" valign="middle"> <?php echo $getthreads3['am']; 
    $date123=$getthreads3['date'];
    
                                     $getdate= "Select * from dadreps where date = $date123"; 
    
                                $getdate2=mysql_query($getdate) or die("Could not get threads"); 
    
                                while ($getdate3=mysql_fetch_array($getdate2)) 
                                    { 

     

    Also when it does work it echos yes the amount of times that there are rows with same date. How could i echo yes no matter how many rows it shows?

  6. but im only wanting these to go through the array

     

       var cell1 = row.insertCell(0);  
                       
                      var str1 = document.createTextNode("Distance: "); 
                      cell1.appendChild(str1); 
                      var input = document.createElement('input'); 
              input.name = 'distance[]' + lastRow;  
              input.id = 'distance' + lastRow;  
                      input.style.width = "187px" 
              cell1.appendChild(input);  
                       
                      var theBR = document.createElement('br'); 
                      cell1.appendChild(theBR); 
                
         var str1 = document.createTextNode("Time: "); 
                      cell1.appendChild(str1);
                      var input2 = document.createElement('input'); 
    input2.value = '00'; 
              input2.name = 'hours[]' + lastRow;
      
              input2.id = 'hours' + lastRow;  
                      input2.style.width = "25px" 
                      input2.setAttribute('maxlength', 1); 
              cell1.appendChild(input2);  
                      var str2 = document.createTextNode(" Hours"); 
                      cell1.appendChild(str2); 
    
              var input3 = document.createElement('input');  
              input3.value = '00';  
    input3.name = 'min[]' + lastRow; 
    
              input3.id = 'min' + lastRow;  
                      input3.style.width = "25px" 
              cell1.appendChild(input3); 
                      var str3 = document.createTextNode(" Minutes"); 
                      cell1.appendChild(str3); 
                       
              var input4 = document.createElement('input');  
            input4.value = '00';
      input4.name = 'seconds[]' + lastRow;
       
              input4.id = 'seconds' + lastRow;  
                      input4.style.width = "25px" 
              cell1.appendChild(input4);  
                      var str4 = document.createTextNode(" Seconds"); 
                      cell1.appendChild(str4); 

     

    and as you can see they are allready in an array ver.

     

    Or do i need them ALL to be like this to have just these work?

  7. I have added a function so i can add more textboxes to the form if needed

    <script language="javascript1.2" type="text/javascript"> 
    function addRow() { 
    
              var tbl = document.getElementById('thetable');  
              var lastRow = tbl.rows.length;  
              var row = tbl.insertRow(lastRow);  
                
              var cell1 = row.insertCell(0);  
                       
                      var str1 = document.createTextNode("Distance: "); 
                      cell1.appendChild(str1); 
                      var input = document.createElement('input'); 
              input.name = 'distance[]' + lastRow;  
              input.id = 'distance' + lastRow;  
                      input.style.width = "187px" 
              cell1.appendChild(input);  
                       
                      var theBR = document.createElement('br'); 
                      cell1.appendChild(theBR); 
                
         var str1 = document.createTextNode("Time: "); 
                      cell1.appendChild(str1);
                      var input2 = document.createElement('input'); 
    input2.value = '00'; 
              input2.name = 'hours[]' + lastRow;
      
              input2.id = 'hours' + lastRow;  
                      input2.style.width = "25px" 
                      input2.setAttribute('maxlength', 1); 
              cell1.appendChild(input2);  
                      var str2 = document.createTextNode(" Hours"); 
                      cell1.appendChild(str2); 
    
              var input3 = document.createElement('input');  
              input3.value = '00';  
    input3.name = 'min[]' + lastRow; 
    
              input3.id = 'min' + lastRow;  
                      input3.style.width = "25px" 
              cell1.appendChild(input3); 
                      var str3 = document.createTextNode(" Minutes"); 
                      cell1.appendChild(str3); 
                       
              var input4 = document.createElement('input');  
            input4.value = '00';
      input4.name = 'seconds[]' + lastRow;
       
              input4.id = 'seconds' + lastRow;  
                      input4.style.width = "25px" 
              cell1.appendChild(input4);  
                      var str4 = document.createTextNode(" Seconds"); 
                      cell1.appendChild(str4); 
    }  
                       
    function delRow() { 
              var tbl = document.getElementById('thetable');  
              var lastRow = tbl.rows.length;  
              if (lastRow > 2) tbl.deleteRow(lastRow - 1);  
    }  
    
    </script> 
    

     

    The whole form is below

     

    <link rel = "stylesheet" href = "http://www.runningprofiles.com/dad/Form.Send/demo.css" type = "text/css"/>
    
    <script type = "text/javascript" src = "http://www.runningprofiles.com/dad/mootools.js"></script>
    
    <script type = "text/javascript" src = "http://www.runningprofiles.com/dad/Form.Send/demo.js"></script>
    <?php
    
    $getthreads = 
                                    "Select * from dad where id='".$_GET["id"]."' ORDER BY date ASC"; 
    
                                $getthreads2=mysql_query($getthreads) or die("Could not get threads"); 
    
                                while ($getthreads3=mysql_fetch_array($getthreads2)) 
                                    { 
    ?>
    <center>
    <form id = "myForm" action = "include/addlog.php" method = "post">   <table style="BORDER-COLLAPSE: collapse">
         <tbody>
           <tr>
             <td>
               <p align="right">Date:</p></td>
             <td>
               <p align="left"><?php echo $getthreads3['date'];?></p>
    <input type="hidden" name="date" value="<?php echo $getthreads3['date'];?>" >
    
    
    </td>
          </tr>
           <tr>
             <td>
    <br />
               <p align="right">Am Run:</p></td>
             <td>
               <p align="left"><br />
                <input style="WIDTH: 186px;" value="<?php echo $getthreads3['am'];?>" name="am" /></p></td>
          </tr>
           <tr>
             <td>
               <p align="right">Duration:</p></td>
             <td>
               <p align="left">
                <input maxlength="2" style="WIDTH: 20px;" name="hoursam" /> Hours<input maxlength="2" style="WIDTH: 20px;" name="minam" /> Minutes<input maxlength="2" style="WIDTH: 25px; " name="secam" />Seconds</p></td>
          </tr>
           <tr>
             <td><br />
               <p align="right">Pm Run:</p></td>
             <td>
               <p align="left"><br />
                <input style="WIDTH: 186px;" value="<?php echo $getthreads3['pm'];?>" name="pm" /></p></td>
          </tr>
           <tr>
             <td>
               <p align="right">Duration:</p></td>
             <td>
               <p align="left">
                <input maxlength="2" style="WIDTH: 25px; " name="hourspm" /> Hours<input maxlength="2" style="WIDTH: 25px;" name="minpm" /> Minutes<input maxlength="2" style="WIDTH: 25px;" name="secpm" /> Seconds</p></td>
          </tr>
                 <tr>
             <td><br />
               <p align="right">Weather:</p></td>
             <td>
               <p align="left"><br />
                <input style="WIDTH: 187px;" name="weather" /></p></td>
          </tr>
           <tr>
             <td><br />
               <p align="right">Comments:</p></td>
             <td>
               <p align="left"><br />
                <input style="WIDTH: 187px;" name="comments" /></p></td>
          </tr>
           <tr>
             <td>
         </td>
             <td>
               <p align="center"> </p></td>
          </tr>
        </tbody>
    
      </table>
    <table id="thetable" align="center">
           <tr> 
    <td>
    </td> 
    </tr> 
    </table> 
    <script language="javascript1.2" type="text/javascript"> 
    function addRow() { 
    
              var tbl = document.getElementById('thetable');  
              var lastRow = tbl.rows.length;  
              var row = tbl.insertRow(lastRow);  
                
              var cell1 = row.insertCell(0);  
                       
                      var str1 = document.createTextNode("Distance: "); 
                      cell1.appendChild(str1); 
                      var input = document.createElement('input'); 
              input.name = 'distance[]' + lastRow;  
              input.id = 'distance' + lastRow;  
                      input.style.width = "187px" 
              cell1.appendChild(input);  
                       
                      var theBR = document.createElement('br'); 
                      cell1.appendChild(theBR); 
                
         var str1 = document.createTextNode("Time: "); 
                      cell1.appendChild(str1);
                      var input2 = document.createElement('input'); 
    input2.value = '00'; 
              input2.name = 'hours[]' + lastRow;
      
              input2.id = 'hours' + lastRow;  
                      input2.style.width = "25px" 
                      input2.setAttribute('maxlength', 1); 
              cell1.appendChild(input2);  
                      var str2 = document.createTextNode(" Hours"); 
                      cell1.appendChild(str2); 
    
              var input3 = document.createElement('input');  
              input3.value = '00';  
    input3.name = 'min[]' + lastRow; 
    
              input3.id = 'min' + lastRow;  
                      input3.style.width = "25px" 
              cell1.appendChild(input3); 
                      var str3 = document.createTextNode(" Minutes"); 
                      cell1.appendChild(str3); 
                       
              var input4 = document.createElement('input');  
            input4.value = '00';
      input4.name = 'seconds[]' + lastRow;
       
              input4.id = 'seconds' + lastRow;  
                      input4.style.width = "25px" 
              cell1.appendChild(input4);  
                      var str4 = document.createTextNode(" Seconds"); 
                      cell1.appendChild(str4); 
    }  
                       
    function delRow() { 
              var tbl = document.getElementById('thetable');  
              var lastRow = tbl.rows.length;  
              if (lastRow > 2) tbl.deleteRow(lastRow - 1);  
    }  
    
    </script> 
    
    <table style="WIDTH: 100%; BORDER-COLLAPSE: collapse"> 
         <tr> 
           <td> 
           <p align="center"> 
              <input type="button" value="Add Interval" onclick="addRow()" /> 
              <input type="button" value="Subtract Interval" onclick="delRow()" /> 
                    </p> 
           </td> 
        </tr> 
    </table> 
    
        <center>
            <input type = "submit" name = "button" id = "submitter"/></center>
    
        <span class = "clr"> <!-- spanner --></span>
    
        </div>
    </form>
    
    <?php } ?>
    <center>
        <div id = "log">
            <center><h3>Added diary</h3>
    
                <div id = "log_res"> <!-- spanner --></center>
        </div>
    
        </div>
    </center>

     

    Now when i come to try add the data to the db it only adds the 1st result from the loop...why??

     

    <?php 
    include '../../settings.php';
    
    $mydate=$_POST['date'];
       $am=mysql_real_escape_string($_POST['am']);
          $minam=mysql_real_escape_string($_POST['minam']);
    $hoursam=mysql_real_escape_string($_POST['hoursam']);
    $secam=mysql_real_escape_string($_POST['secam']);
       $pm=mysql_real_escape_string($_POST['pm']);
          $minpm=mysql_real_escape_string($_POST['minpm']);
    $hourspm=mysql_real_escape_string($_POST['hourspm']);
    $secpm=mysql_real_escape_string($_POST['secpm']);
    $weather=mysql_real_escape_string($_POST['weather']);
    $comments=mysql_real_escape_string($_POST['comments']);
    
    if($am != ""){$amtime = $hoursam . ":" . $minam. ".". $secam;}
    if($pm != ""){$pmtime = $hourspm . ":" . $minpm. ".". $secpm;}
    mysql_query("INSERT INTO daddiary (`date`,`am`,`pmtime`,`pm`,`amtime`,`weather`,`comment`) VALUES ('$mydate','$am' , '$amtime','$pm','$pmtime' , '$weather','$comments') ") or die(mysql_error());
    
    
    
    $i=-1;
    $limit=count($_POST['date']);
    while(++$i<$limit)
    {
    if ($_POST['distance'] != "") {
    
          $mydate=$_POST['date'];
       $distance=mysql_real_escape_string($_POST['distance'][$i]);
          $min=mysql_real_escape_string($_POST['min'][$i]);
    $hours=mysql_real_escape_string($_POST['hours'][$i]);
    $sec=mysql_real_escape_string($_POST['seconds'][$i]);
      
    $time = $hours . ":" . $min. ".". $sec;
    echo $time;
    
       mysql_query("INSERT INTO dadreps (`date`,`distance`,`time`) VALUES ('$mydate','$distance' , '$time') ") or die(mysql_error());
    
    }
    }
    
      echo 'Your diary entry has been added';
    
    ?>

  8. 23/05/2010  10,000m  Track  BMAF 10k - Oxford  Set a PB 

    15/05/2010  Other  Road  BMAF Road Relays - Sutton Park, Birmingham  Get in the team! 

    06/06/2010  10,000m  Road  10km Road Championship - Bispham, Blackpool  Set a PB! 

     

     

    Is how its showing it... im using a query  $getthreads ="Select * from races ORDER BY DATE_FORMAT(date, '%d-%m-%Y') ASC";

     

    what am i doing wrong??

  9. ver dump gets me

     

    Array

    (

        [date] => 14/03/2010

        [venue] => 1

        [goals] => 1

        [date2] => 14/03/2010

        [venue2] => 2

        [goals2] => 2

        [date3] => 14/03/2010

        [venue3] => 3

        [goals3] => 3

        [distance] => 5000m

        [terrain] => Road

        [distance2] => 3000m

        [terrain2] => Track

        [distance3] => 10,000m

        [terrain3] => Cross Country

    )

     

    if that helps at all

  10. Below is the full code to add races to my db.

     

    <link rel="stylesheet" href="http://www.runningprofiles.com/dad/Form.Send/demo.css" type="text/css" />
    
    <script type="text/javascript" src="http://www.runningprofiles.com/dad/mootools.js"></script>
    
    <script type="text/javascript" src="http://www.runningprofiles.com/dad/Form.Send/demo.js"></script>
    
    
    
    <script> 
    
    
    
    function addRow() {   
    
              var tbl = document.getElementById('thetable');   
    
              var lastRow = tbl.rows.length;   
    
              var row = tbl.insertRow(lastRow);   
    
                 
    
              var cell1 = row.insertCell(0);   
    
                      cell1.setAttribute('align','center') 
    
              var input = document.createElement('input');   
    
              input.name = 'date' + lastRow;   
    
              input.id = 'date' + lastRow;   
    
              cell1.appendChild(input);  
    
    
    
    var cell2 = row.insertCell(1);   
    
                    cell2.setAttribute('align','center') 
    
              input = document.createElement('input');   
    
              input.name = 'goals' + lastRow;   
    
              input.id = 'goals' + lastRow;   
    
              cell2.appendChild(input);  
    
                 
    
              var cell3 = row.insertCell(1);   
    
                    cell3.setAttribute('align','center') 
    
              input = document.createElement('input');   
    
              input.name = 'venue' + lastRow;   
    
              input.id = 'venue' + lastRow;   
    
              cell3.appendChild(input);   
    
      
    
    var cell4 = row.insertCell(1);    
    
                    cell4.setAttribute('align','center'); 
    
                     
    
                    input = document.createElement('select');    
    
                    input.name = 'terrain' + lastRow; 
    
                    input.id = 'terrain' + lastRow; 
    
                     
    
                    var s = "Road/Track/Multi Terrain/Cross Country".split("/"); 
    
                    for(var i=0;i<s.length;i++) { 
    
                            var o = document.createElement("option"); 
    
                            o.value = s[i]; 
    
                            o.text = s[i]; 
    
                            input.add(o); 
    
                    } 
    
             
    
                    cell4.appendChild(input); 
    
            var cell5 = row.insertCell(1);    
    
                    cell5.setAttribute('align','center'); 
    
                     
    
                    input = document.createElement('select');    
    
                    input.name = 'distance' + lastRow; 
    
                    input.id = 'distance' + lastRow; 
    
                     
    
                    var s = "3000m/5000m/10,000m/5 Miles/10 Miles/20 Miles/Half Marathon/Marathon /Other".split("/"); 
    
                    for(var i=0;i<s.length;i++) { 
    
                            var o = document.createElement("option"); 
    
                            o.value = s[i]; 
    
                            o.text = s[i]; 
    
                            input.add(o); 
    
                    } 
    
             
    
                    cell5.appendChild(input); 
    
      
    
    } 
    
    
    
        function delRow() {  
    
              var tbl = document.getElementById('thetable');   
    
              var lastRow = tbl.rows.length;   
    
              if (lastRow > 2) tbl.deleteRow(lastRow - 1);   
    
         } 
    
    
    
    
    
    </script>
    
    <br />
    
    <center>
    
    Here is a list of you up and coming races. Use the form below to add them so then <b>I</b> know which races you have gone for!
    
    
    
    </center>
    
        <br />
    
    <table width = "99%" class = 'forum'> 
    
                    <tr> 
    
                        <td> 
    
                            <table width="100%" class = 'maintable'> 
    
                                <tr class = 'headline'> 
    
                                <td width = "12%" bgcolor="#003366"> 
    
                                        <div align = "center">Date</div></td> 
    
    
    
                                    <td width = "14%" bgcolor="#003366"> 
    
                                       <div align = "center">Terrain</div></td> 
    
    
    
                                    <td width = "12%" bgcolor="#003366"> 
    
                                         <div align = "center">Distance</div>                                   </td> 
    
    
    
                                    <td width = "43%" bgcolor="#003366"> 
    
                                        <div align = "center">Venue
    
                                        </div></td> 
    
    
    
                                    <td width = "19%" bgcolor="#003366"> 
    
                                        <div align = "center">Goals</div></td> 
    
                                </tr> 
    
    
    
                            <?php 
    
    //$query="DELETE FROM dad WHERE id = '22' ";
    
    //$result=mysql_query($query);
    
    
    
                                                     $getthreads = 
    
                                    "Select * from races ORDER BY date ASC"; 
    
    
    
                                $getthreads2=mysql_query($getthreads) or die("Could not get threads"); 
    
    
    
                                while ($getthreads3=mysql_fetch_array($getthreads2)) 
    
                                    { 
    
                                     
    
                          
    
                                    ?><tr <? if ( $getthreads3['date'] == date("d/m/Y") ) { echo 'bgcolor="#CAD9D9"'; }?> > 
    
    <td width="10%" height="39" align="center" valign="middle"><?php 
    
                                echo $getthreads3['date'];?> 
    
    
    
                                    </td>  
    
    <td width="15%" align="center" valign="middle"> <?php echo $getthreads3['distance']; ?>  
    
                                    </td>   
    
    <td width="15%" align="center" valign="middle"><?php echo $getthreads3['terrain']; ?>  
    
                           </td><td align = "center" valign = "middle"><?php echo $getthreads3['venue']?> </td> 
    
    
    
                                    <td align="center" valign = "middle"> 
    
    <?php echo $getthreads3['goals']?>
    
    
    
    </td> 
    
    
    
                           
    
                                        </tr> 
    
                                <?php      } 
    
                            ?> 
    
                      </table></td> 
    
                    </tr> 
    
    </table>
    
        
    
    
    
    <form id="myForm" action="Form.Send/ajax.form.php" method="post">
    
        
    
         <table align="center" style="WIDTH: 100%;BACKGROUND: #C0C0C0; BORDER-COLLAPSE: collapse" id="thetable"> 
    
       <tbody> 
    
         <tr> 
    
           <td> 
    
             <p align="center">Date</p></td> 
    
           <td> 
    
             <p align="center">Distance</p></td> 
    
           <td> 
    
             <p align="center">Terrain</p></td>
    
    <td> 
    
             <p align="center">place</p></td>  
    
           <td> 
    
             <p align="center">Goals</p></td> 
    
        </tr> 
    
         <tr> 
    
           <td align="center"> 
    
            <input  name="date" value="<?php echo date("d/m/Y");?> " /></td> 
    
           <td align="center">
    
            <select name="distance">
    
    <option value="3000m">3000m</option>
    
    <option value="5000m">5000m</option>
    
    <option value="10,000m">10,000m</option>
    
    <option value="5 Miles">5 Miles</option>
    
    <option value="10 Miles">10 Miles</option>
    
    <option value="20 Miles">20 Miles</option>
    
    <option value="Half Marathon">Half Marathon</option>
    
    <option value="Marathon">Marathon</option>
    
    <option value="Other">Other</option>
    
    </select>
    
             </td> 
    
           <td align="center"> 
    
           <select name="terrain">
    
    <option value="Road">Road</option>
    
    <option value="Track">Track</option>
    
    <option value="Multi Terrain">Multi Terrain</option>
    
    <option value="Cross Country">Cross Country</option>
    
    </select>
    
    </td> 
    
           <td align="center"> 
    
            <input  name="venue" /></td> 
    
    <td align="center"> 
    
            <input  name="goals" /></td> 
    
        </tr> 
    
      </tbody> 
    
    </table> 
    
    <table style="WIDTH: 100%; BORDER-COLLAPSE: collapse"> 
    
         <tr> 
    
           <td> 
    
           <p align="center"> 
    
              <input type="button" value="Add Anouther" onclick="addRow()" /> 
    
              <input type="button" value="Subtract Row" onclick="delRow()" /> 
    
                    </p> 
    
           </td> 
    
        </tr> 
    
    </table> 
    
    
    
    <center>
    
    
    
    		<input type="submit" name="button" id="submitter" /></center>
    
    	<span class="clr"><!-- spanner --></span>
    
    	</div>
    
            
    
            
    
            
    
    </form>
    
        
    
        <center>
    
        
    
        
    
    <div id="log">
    
    	<center><h3>Ajax Response</h3>
    
    	<div id="log_res"><!-- spanner --></center></div>
    
    </div>
    
    </center>
    
    <span class="clr"><!-- spanner --></span>
    
    

     

     

    As you can see there is an option to add a number of rows so you can add more than 1 race... what would i need to do to add all races the user inputs?? a loop of some kind?

  11. so if i did this

     

    function check_input($data)
    {
        $data = trim($data);
        $data = stripslashes($data);
        $data = htmlspecialchars($data);
        $data = mysql_real_escape_string($data) ;
        return $data;
    }
    
    

     

    would that work to prevent both sql and cross site??

     

    mysql_real_escape_string()

  12. Hey guys i have a script below where i can add other input boxes if needed.... these are then numberd plusing 1 to each one.

     

    How can i make sure they are all added to my db?

     

    An output might look liek this

     

    Array ( [date] => 1 [am] => 1 [pm] => 1 [comment] => 1 [date2] => w [am2] => w [pm2] => w [comment2] => w [date3] => 1 [am3] => 1 [pm3] => 1 [comment3] => 1 [date4] => g [am4] => g [pm4] => g [comment4] => g )

     

     

    <script>  
            function addRow() {  
              var tbl = document.getElementById('thetable');  
              var lastRow = tbl.rows.length;  
              var row = tbl.insertRow(lastRow);  
                
              var cell1 = row.insertCell(0);  
              var input = document.createElement('input');  
              input.name = 'date' + lastRow;  
              input.id = 'date' + lastRow;  
              cell1.appendChild(input);  
                
              var cell2 = row.insertCell(1);  
              input = document.createElement('input');  
              input.name = 'am' + lastRow;  
              input.id = 'am' + lastRow;  
              cell2.appendChild(input);  
                
              var cell3 = row.insertCell(2);  
              input = document.createElement('input');  
              input.name = 'pm' + lastRow;  
              input.id = 'pm' + lastRow;  
              cell3.appendChild(input);  
                
              var cell4 = row.insertCell(3);  
              input = document.createElement('input');  
              input.name = 'comment' + lastRow;  
              input.id = 'comment' + lastRow;  
              cell4.appendChild(input);  
            }  
              
            function delRow() {  
              var tbl = document.getElementById('thetable');  
              var lastRow = tbl.rows.length;  
              if (lastRow > 2) tbl.deleteRow(lastRow - 1);  
            }  
        </script>  
    
    <form action="javascript:get(document.getElementById('myform'));" name="myform" id="myform"> 
    <table style="WIDTH: 100%; BORDER-COLLAPSE: collapse" id="thetable">  
       <tbody>  
         <tr>  
           <td>  
             <p align="center">Date</p></td>  
           <td>  
             <p align="center">Am</p></td>  
           <td>  
             <p align="center">Pm</p></td>  
           <td>  
             <p align="center">Comment</p></td>  
        </tr>  
         <tr>  
           <td>  
            <input name="date" /> </td>  
           <td>  
            <input name="am" /> </td>  
           <td>  
            <input name="pm" /></td>  
           <td>  
            <input name="comment" /></td>  
        </tr>  
      </tbody>  
    </table>  
    <table style="WIDTH: 100%; BORDER-COLLAPSE: collapse">  
         <tr>  
           <td>  
           <p align="center">  
              <input type="button" value="Add Row" onclick="addRow()" />  
              <input type="button" value="Subtract Row" onclick="delRow()" />  
                    </p>  
           </td>  
        </tr>  
    </table>

  13. Below is a script to edit a forum post but the issue is it edits all the forums posts to the same message e.g

     

    b4

     

    post1 = hey

    post2= how

    post3= are

    post4= you

     

    Now i select post 1 to be changed to 123

     

    it should look like this:

     

    post1 = 123

    post2= how

    post3= are

    post4= you

     

    but looks like this

     

    post1 = 123

    post2= 123

    post3= 123

    post4= 123

     

     

    <?php 
         
    if (isset($_POST['edit'])) { 
    $message =  mysql_real_escape_string($_POST['message']); 
           $query = "UPDATE forumtutorial_posts SET  post = '$message' WHERE postid=".$getreplies3['postid']." ";           
             mysql_query($query) or die('Error, query failed'); 
    }
    else
    { 
    echo $getreplies3['postid']      ;
    $threadid =  $CONT_ID;     
    ?> 
    
    <script src="../../css/SpryCollapsiblePanel.js" type="text/javascript"></script> 
          <link href="http://www.runningprofiles.com/css/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css" /> 
          <div id="CollapsiblePanel<?PHP 
           // I had to add $CONT_ID that is set in the script that includes this. and ive done it again for the "tabindex" just to ensure it works!
          echo $CONT_ID; ?>" class="CollapsiblePanel"> 
      <div class="CollapsiblePanelTab" tabindex="<?PHP echo $CONT_ID; ?>"> Edit</div> 
      <div class="CollapsiblePanelContent"> 
    <form name='input' action='<?php echo $filename ;?>' method='post'> 
          <div align="center"> 
          <label> 
          <textarea class='inputforum' name="message" id="message" cols="500" rows="5"><? echo $message; ?></textarea> 
          </label> 
                <input type="checkbox" name="deletepost" value="deletepost" /> 
         delete post <br/> 
          <br/> 
           
           
            <input type='submit' name='edit' class="submit-btn"  value='' /> 
      </div> 
    </form>      <? 
    } 
    ?></div> 
    </div> 
    
    
    <script type="text/javascript"> 
    <!-- 
    <?PHP
    //Ive added the variable $CONT_ID here aswell. THIS IS REQUIRED FOR THE
    //JS to work!
    ?>
    var CollapsiblePanel<?PHP echo $CONT_ID; ?> = new Spry.Widget.CollapsiblePanel("CollapsiblePanel<?PHP echo $CONT_ID; ?>", {contentIsOpen:false}); 
    //--> 
          </script>

  14. Sure thing

     

    // Find out the total number of pages depending on the limit set
        $numofpages=$rows / $page_rows;
        $totalpages=ceil($numofpages);
        // Start links for pages
        $maxpage   =$totalpages == 0 ? 1 : $totalpages;                   // add this line
        echo "Page " . $pagenum . " of " . $maxpage . "</center>"; // change this
    
    
    
       // Sets link for previous 25 and return to page 1
        
         if ($pagenum != 1)
            {
            $pageprev=($pagenum - 1);
            echo "<center><a href=\"" . $_SERVER['PHP_SELF']
                     . "?page=message&forum=$forum&id=$forumpostid&pagenum=1\"><<</a>  ";
            echo "<a href=\"" . $_SERVER['PHP_SELF']
                     . "?page=message&forum=$forum&id=$forumpostid&pagenum=$pageprev\">PREV </a> ";
            }
        else
            {
            echo "<center>PREV ";
            }
       
    
        // Loop thru all the pages and echo out the links
        for ($i=1; $i <= $numofpages; $i++)
            {
            if ($i == $pagenum)
                {
                echo "[" . $i . "] ";
                }
            else
                {
                echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=message&forum=$forum&id=$forumpostid&pagenum=$i\">$i</a> ";
                }
            }
    
        // Check for straglers after the limit blocks
        if (($rows % $page_rows) != 0)
            {
            if ($i == $pagenum)
                {
                echo "[" . $i . "] ";
                }
            else
                {
                echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=message&forum=$forum&id=$forumpostid&pagenum=$i\">$i</a> ";
                }
            }
    
         // Print out the Next 25 and Goto Last page links
    if (($rows - ($page_rows * $pagenum)) > 0)
            {
            $pagenext=$pagenum++;
            echo "<a href=\"" . $_SERVER['PHP_SELF']
                     . "?page=message&forum=$forum&id=$forumpostid&pagenum=$pagenext\">NEXT </a>  ";
            echo "<a href=\"" . $_SERVER['PHP_SELF']
                     . "?page=message&forum=$forum&id=$forumpostid&pagenum=$totalpages\">>></a>  </center>";
            }
        else
            {
            echo("NEXT </center> <br />");
            }
        

×
×
  • 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.