Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts

    drop down forum is only working once

    hey guys not sure if this is where to post but i will go anyways,,,

    ok so below is my forum script in full

    PHP Code:
    <link rel="stylesheet" type="text/css" href="http://www.runningprofiles.com/css/login.css">
    <link rel="stylesheet" type="text/css" href="http://www.runningprofiles.com/members/include/style.css">


    <?php
    require_once '../settings.php';
    include 
    "connect.php"//mysql db connection here
    $id $_SESSION['user_id'];
    $puser get_username($id);

    $timestamp time();
    $timeout $timestamp 180;
    $username get_username($_SESSION['user_id']);
    function 
    selfURL()
    {
        
    $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" "";
        
    $protocol strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/") . $s;
        
    $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":" $_SERVER["SERVER_PORT"]);
        return 
    $protocol "://" $_SERVER['SERVER_NAME'] . $port $_SERVER['REQUEST_URI'];
    }
    function 
    strleft($s1$s2)
    {
        return 
    substr($s10strpos($s1$s2));
    }
    $filename = (selfURL());
    //Insert User
    $insert mysql_query("REPLACE INTO `useronline` SET `timestamp`='$timestamp', `ip`='" .
        
    $_SERVER['REMOTE_ADDR'] . "', `file`='$filename',`user`='$username',`user_id`='" .
        
    $_SESSION['user_id'] . "'") or die(mysql_error());

    ?>
    <?php

    //look to see if the forum is currently locked
    $sQry "SELECT `locked` FROM forum_lock LIMIT 1";
    $obQry mysql_query($sQry) or die(sprintf("Could not query forums (%d): %s",
        
    mysql_errno(), mysql_error()));
    $record mysql_fetch_array($obQry);
    if (isset(
    $record['locked']) && $record['locked'])
    {
        
    //error message
        
    die("Sorry, the forums are currently locked.");
    }
    else
    {
    //if ok carry on viewing page

    //This checks to see if there is a page number. If not, it will set it to page 1
    if (!(isset($pagenum)))
    {
        
    $pagenum 1;
    }

    //Here we count the number of results
    //Edit $data to be your query
    $forum $_GET['forum'];
    $data mysql_query("Select * from forumtutorial_posts where parentid='0' AND forum = '$forum' ORDER BY important, lastrepliedto") or
        die(
    mysql_error());
    $rows mysql_num_rows($data);

    //This is the number of results displayed per page
    $page_rows 25;

    //This tells us the page number of our last page
    $last ceil($rows $page_rows);

    //this makes sure the page number isn't below one, or more than our maximum pages
    if ($pagenum 1)
    {
        
    $pagenum 1;
    } elseif (
    $pagenum $last)
    {
        
    $pagenum $last;
    }

    //This sets the range to display in our query
    $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

    {
    ?>
    <p><A href='index.php?page=mainforums'><img src="http://www.runningprofiles.com/images/homeforum.gif" alt="home" border="0"  /></a><A href='index.php?page=post&forum=<?php echo
    $forum?>'><img src="http://www.runningprofiles.com/images/new_post.gif" border="0"  /></a></p>
    <p>users viewing forum = <?php if ($result mysql_query("SELECT * FROM useronline"))
        {
            if (
    mysql_num_rows($result))
            {
                while (
    $row mysql_fetch_array($result))
                {
                    
    $last_active time() - $row['timestamp'];
                    if (
    $last_active 3600)
                    {
                        
    $onlineuser[] = $row['user'];
                    }
                }
            }
        }

        if (isset(
    $onlineuser))
        {
            if (
    count($onlineuser) == 1)
            {
                echo 
    $onlineuser[0];
            }
            else
            {
                for (
    $i 0$i count($onlineuser); $i++)
                {
                    if (
    $i == count($onlineuser) - 1)
                    {
                        echo 
    " and " $onlineuser[$i];
                    }
                    else
                    {
                        echo 
    "  " $onlineuser[$i];
                    }
                }
            }
        }

    ?>

    </p>
    <table width="99%" class='forum'>
      <tr>
        <td><table class='maintable'>

    <tr class='headline'><td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>Topic</td>
      <td width=15%>Topic Starter</td>
    <td width="5%">Replies</td><td width="25%">Last replied time</td></tr>
    <?

        $getthreads 
    "Select * from forumtutorial_posts where parentid='0' and forum = '$forum' ORDER BY important ASC, lastrepliedto DESC $max";


        
    $getthreads2 mysql_query($getthreads) or die("Could not get threads");

        while (
    $getthreads3 mysql_fetch_array($getthreads2))
        {

            
    $getthreads3[title] = strip_tags($getthreads3[title]);

            
    $getthreads3[author] = strip_tags($getthreads3[author]);
            
    $getthreads3[important] = strip_tags($getthreads3[important]);
            
    $important $getthreads3['important'];
    ?>
     <tr <?php if ($important == 1)
            {
                
    $class "mainrow1";
            }
            else
            {
                
    $class "mainrow";
            } 
    ?> class="<? echo $class ?>"><td width="6%" height="39" align="center" valign="middle"><? if ($getthreads3[author] ==
    $puser)
            { 
    ?> <img src="http://www.runningprofiles.com/images/new_posts_icon.gif" alt="My" /> <? }
            else
            { 
    ?> <img src="http://www.runningprofiles.com/images/last_post.gif" alt="My" /> <? ?>
       <td width="4%" align="center" valign="middle"><?php if ($getthreads3['forumlock'] ==
    1)
            {
                echo 
    ' <img src="http://www.runningprofiles.com/images/quick_lock.gif" alt="locked"/>';
            }
            if (
    $getthreads3['important'] == 1)
            {
                echo 
    '<img src="http://www.runningprofiles.com/images/sticky.gif" alt="sticky"/>';
            } 
    ?></td>
    <td width="45%" valign="top"><div align="left"><a href='index.php?page=message&forum=<? echo
    $forum?>&id=<? echo
    $getthreads3[postid?>'><? echo
    $getthreads3[title?></a>  
      
       <?php if ($id == 1)
            {
                include 
    'editforum.php';
            }
            ; 
    ?>
          </div></td>
      <td align="left" valign="middle"><a href='/members/<? echo $getthreads3[author]; ?>'><? echo
    $getthreads3[author?></a></td>
      <td align="center" valign="top"><? echo $getthreads3[numreplies?></td>
      <td valign="top"><? $dbtime $getthreads3['lastrepliedto'];
            
    $time date("F j Y, g:i a"$dbtime);
            echo 
    $time?><br>
      Last post by <b><? echo $getthreads3[lastposter?> </b></td></tr>
    <?
        
    }
    ?>
    </table></td>
      </tr>
    </table>
    <br>


    </a>
    <p>
      <?
        
    echo "<br>";
    }
    echo 
    "<p>";


    // Start links for pages
    $maxpage $totalpages == $totalpages// add this line
    echo "<p align=center>Page $pagenum of $maxpage <br /> "// change this

    // Sets link for previous 25 and return to page 1
    if ($pagenum != 1)
    {
        
    $pageprev = ($pagenum 1);
        echo 
    "<a href=\"" $_SERVER['PHP_SELF'] . "?page=message&id=$id&pagenum=1\"><<</a>&nbsp;&nbsp;";
        echo 
    "<a href=\"" $_SERVER['PHP_SELF'] . "?page=message&id=$id&pagenum=$pageprev\">PREV&nbsp;</a> ";
    }
    else
    {
        echo 
    "";
    }

    // 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&id=$id&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&id=$id&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&id=$id&pagenum=$pagenext\">NEXT&nbsp;</a>&nbsp;&nbsp;";
        echo 
    "<a href=\"" $_SERVER['PHP_SELF'] . "?page=message&id=$id&pagenum=$totalpages\">>></a>&nbsp;&nbsp;";
    }
    ?>
    </p>
    <p></p>
    <table width="14%" border="0" align="left" cellpadding="0" cellspacing="0">
      <tr>
        <td height="33" colspan="2" align="center"><strong>forum key</strong></td>
      </tr>
      <tr>
        <td width="22%" align="center"><img src="http://www.runningprofiles.com/images/quick_lock.gif" alt="locked"/></td>
        <td width="78%">Locked Topic</td>
      </tr>
      <tr>
        <td align="center" valign="middle"><img src="http://www.runningprofiles.com/images/sticky.gif" alt="sticky"/></td>
        <td>Sticky Topic</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table>
    <?php ?>
    to break it down abit more towards the end of this script a image can be seen to which it looks like but ill tell you more about the script...

    so
    PHP Code:
    <?php if ($id == 1)
            {
                include 
    'editforum.php';
            }
            ; 
    ?>
    will show this page

    PHP Code:
    <?php
          $topicid
    =$_GET['id'];
    if (isset(
    $_POST['edit'])) {
                  if (
    $_POST['deletepost'] == 'deletepost'){
            
    $threadid =  mysql_real_escape_string$_POST['id']);
            
    mysql_query("DELETE FROM forumtutorial_posts WHERE postid='$threadid'"
    or die(
    mysql_error());
    mysql_query("UPDATE `forumtutorial_posts` SET `numreplies`=`numreplies`-'1' WHERE `postid`='$topicid'"
    or die(
    mysql_error()); 
    header"refresh: 0; url=http://www.runningprofiles.com/members/index.php?page=message&forum=general&id=$id");  
        } else {
        
    $threadid =  mysql_real_escape_string$_POST['id']);
        
    $message $_POST['message'];
        echo 
    $message
         
    $query "UPDATE forumtutorial_posts SET  post = '$message' WHERE postid='$threadid' ";
        
    mysql_query($query) or die('Error, query failed');
        
    header"refresh: 0; url=http://www.runningprofiles.com/members/index.php?page=message&forum=general&id=$id");  
        
    }



        


    }else{


    ?>

    <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="CollapsiblePanel1" class="CollapsiblePanel">
      <div class="CollapsiblePanelTab" tabindex="0"> Edit</div>
      <div class="CollapsiblePanelContent">
    <form name='input' action='index.php?page=message&forum=general&id=<? echo $id ?>' method='post'>
        <input type="hidden" name="id" value="<?php echo $getreplies3['postid'?>">
        <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">
    <!--
    var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1", {contentIsOpen:false});
    //-->
          </script>
    now i would show you the css and js files that you can be seen included but surly this is not the problem is it works on the first post...

    i have included a image below of what my view currently looks like



    the wierd thing is that as you can see the top one has the button the when pressed it shows what it shown the the forum threads below... the thing is anything below the top on doesnot act at a button and i have no idea why!


    if there is anymore information i can give i gladly will to sort this out!

  • #2
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    could it be due to this ..
    Code:
    PHP Code:
    var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1", {contentIsOpen:false}); 
    only doing the 1st 1??

  • #3
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    humm there all id="CollapsiblePanel1"

    any way to change it in a loop or something

    so its

    id="CollapsiblePanel1"
    id="CollapsiblePanel2"
    id="CollapsiblePanel3"

  • #4
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    i tried this
    PHP Code:
    <?php
    $i 
    1;
    while(
    $i<20)
    {
    echo 
    "id='CollapsiblePanel".$i;
    $i++;
    }
    ?>
    but it gives me id=id='CollapsiblePanel1id='CollapsiblePanel2id='CollapsiblePanel3id='CollapsiblePanel4id='Collapsib lePanel5id='CollapsiblePanel6id='CollapsiblePanel7id='CollapsiblePanel8id='C

  • #5
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    any ideas so i can get this solved on mwhy it oes 1st onebut not the resT??

  • #6
    New Coder
    Join Date
    Jul 2008
    Posts
    91
    Thanks
    4
    Thanked 9 Times in 9 Posts
    Here we go... this is a modified version of the editforum.php (just the lower part)

    PHP Code:
    <script src="../../css/SpryCollapsiblePanel.js" type="text/javascript"></script> 
          <link href="http://www.runningprofiles.com/css/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css" /> 
    <?PHP
    //We need to add a loop here:
    for($i 1$i mysql_num_rows($getthreads2); $i++){
          
    ?><div id="CollapsiblePanel<?PHP echo $i?>" class="CollapsiblePanel"> 
      <div class="CollapsiblePanelTab" tabindex="<?PHP echo $i 1?>"> Edit</div> 
      <div class="CollapsiblePanelContent"> 
    <form name='input' action='index.php?page=message&forum=general&id=<? echo $id ?>' method='post'> 
        <input type="hidden" name="id" value="<?php echo $getreplies3['postid'?>"> 
        <div align="center"> 
          <label> 
          <textarea class='inputforum' name="message" id="message" cols="500" rows="5"><? echo $message?></textarea> 
          </label> 
                <input type="checkbox" name="dcodeeletepost" value="deletepost" /> 
         delete post<br/> 
          <br/> 
           
           
            <input type='submit' name='edit' class="submit-btn"  value=''/> 
      </div> 
    </form></div> 
    </div>
          <? 
    }

    ?>

     <script type="text/javascript"> 
    <!-- 
    <?PHP
    // We need a loop in here aswell:
    for($i 1$i mysql_num_rows($getthreads2); $i++){
    echo(
    'var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1", {contentIsOpen:false});'); 
    }
    ?>

    //--> 
          </script>
    That *should* work, if any problems, just shout!

  • #7
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    hey sadly not for some reason the following happend



    tried messing with it with no improvements....

    i dont undertsand why this is happening or how really to solve it so more help would be gr8

  • #8
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    bmping

  • #9
    New Coder
    Join Date
    Jul 2008
    Posts
    91
    Thanks
    4
    Thanked 9 Times in 9 Posts
    right ok... well... try this and see:

    PHP Code:
    <script src="../../css/SpryCollapsiblePanel.js" type="text/javascript"></script>  
          <link href="http://www.runningprofiles.com/css/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css" />  
    <?PHP 
    //We need to add a loop here: 
    for($i 1$i mysql_num_rows($getthreads2); $i++){ 
          
    ?><div id="CollapsiblePanel<?PHP echo $i?>" class="CollapsiblePanel">  
      <div class="CollapsiblePanelTab" tabindex="<?PHP echo $i 1?>"> Edit</div>  
      <div class="CollapsiblePanelContent">  
    <form name='input' action='index.php?page=message&forum=general&id=<? echo $id ?>' method='post'>  
        <input type="hidden" name="id" value="<?php echo $getreplies3['postid'?>">  
        <div align="center">  
          <label>  
          <textarea class='inputforum' name="message" id="message" cols="500" rows="5"><? echo $message?></textarea>  
          </label>  
                <input type="checkbox" name="dcodeeletepost" value="deletepost" />  
         delete post<br/>  
          <br/>  
            
            
            <input type='submit' name='edit' class="submit-btn"  value=''/>  
      </div>  
    </form></div>  
    </div> 

          <?  
    echo('<script type="text/javascript">  
    var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1", {contentIsOpen:false});
    </script>'
    );

    }  
    ?>
    And can you link me to the site to see whats happening?

  • #10
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    PHP Code:
    <?php

        

    if (isset($_POST['edit'])) {

        if(isset(
    $_POST['forumlock'])){

            
    $forumlock=1;

        }else{

            
    $forumlock=0;

        }

              if(isset(
    $_POST['important'])){

                     
    $important=1;

                }else{

                      
    $important=2;

        }

        
    $threadid =  mysql_real_escape_string$_POST['id']);

        
    $title $_POST['title'];

        
    $query "UPDATE forumtutorial_posts SET forumlock = '$forumlock', important = '$important', title = '$title' WHERE postid='$threadid' ";

        
    mysql_query($query) or die('Error, query failed');

        
    header"refresh: 0; url=http://www.runningprofiles.com/members/index.php?page=forum&forum=$forum"); 

    }else{

        
    $check '';

        if(
    $getthreads3['forumlock']==1) {

            
    $check "checked";

        }

    $forumlock=0;// default value if it's not set

        
    $checkimpor '';

        if(
    $getthreads3['important']==1) {

            
    $checkimpor "checked";

        }

    $important=0;// default value if it's not set



    ?>

    <script src="../css/SpryCollapsiblePanel.js" type="text/javascript"></script>

          <link href="../css/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css" />

          <div id="CollapsiblePanel1" class="CollapsiblePanel">

      <div class="CollapsiblePanelTab" tabindex="0"> Edit</div>

      <div class="CollapsiblePanelContent">

    <form name='input' action='index.php?page=forum&forum=<? echo $forum ?>' method='post'>

        

        <div align="center">Title:

          <input class='inputforum' name='title' type='text' value='<? echo $getthreads3[title];?>' />

          <br/>

          

          <input type='checkbox' name='forumlock' <? echo  $check ?>

          Lock a Room<br/>

          <input type='checkbox' name='important' <? echo  $checkimpor ?>

          Important<br/>

          <input type="hidden" name="id" value="<?php echo $getthreads3[postid?>">

            <input type='submit' name='edit' class="submit-btn"  value=''/>

        </div>

    </form>      <?

    }

    ?></div>

    </div>





          <script type="text/javascript">

    <!--

    var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1", {contentIsOpen:false});

    //-->

          </script>
    the above is a edit bit of my code i have your code but sadly it didnt work


    to check out the error go to http://www.runningprofiles.com then login with username and password as demo

    then go to forum --> general and you will see what is happening.... very strange

  • #11
    New Coder
    Join Date
    Jul 2008
    Posts
    91
    Thanks
    4
    Thanked 9 Times in 9 Posts
    Ah ha! right, i need the lastest revision of the code at the top of the page, then i can modify it!


    Oh and another thing, id suggest you sort your your HTML. especially the head...

  • #12
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    OK so i have

    forum.php

    PHP Code:
    <link rel="stylesheet" type="text/css" href="http://www.runningprofiles.com/css/login.css">
    <link rel="stylesheet" type="text/css" href="http://www.runningprofiles.com/members/include/style.css">


    <?php
    require_once '../settings.php';
    include 
    "connect.php"//mysql db connection here
    $id $_SESSION['user_id'];
    $puser get_username($id);

    $timestamp time();
    $timeout $timestamp 180;
    $username get_username($_SESSION['user_id']);
    function 
    selfURL()
    {
        
    $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" "";
        
    $protocol strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/") . $s;
        
    $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":" $_SERVER["SERVER_PORT"]);
        return 
    $protocol "://" $_SERVER['SERVER_NAME'] . $port $_SERVER['REQUEST_URI'];
    }
    function 
    strleft($s1$s2)
    {
        return 
    substr($s10strpos($s1$s2));
    }
    $filename = (selfURL());
    //Insert User
    $insert mysql_query("REPLACE INTO `useronline` SET `timestamp`='$timestamp', `ip`='" .
        
    $_SERVER['REMOTE_ADDR'] . "', `file`='$filename',`user`='$username',`user_id`='" .
        
    $_SESSION['user_id'] . "'") or die(mysql_error());

    ?>
    <?php

    //look to see if the forum is currently locked
    $sQry "SELECT `locked` FROM forum_lock LIMIT 1";
    $obQry mysql_query($sQry) or die(sprintf("Could not query forums (%d): %s",
        
    mysql_errno(), mysql_error()));
    $record mysql_fetch_array($obQry);
    if (isset(
    $record['locked']) && $record['locked'])
    {
        
    //error message
        
    die("Sorry, the forums are currently locked.");
    }
    else
    {
    //if ok carry on viewing page

    //This checks to see if there is a page number. If not, it will set it to page 1
    if (!(isset($pagenum)))
    {
        
    $pagenum 1;
    }

    //Here we count the number of results
    //Edit $data to be your query
    $forum $_GET['forum'];
    $data mysql_query("Select * from forumtutorial_posts where parentid='0' AND forum = '$forum' ORDER BY important, lastrepliedto") or
        die(
    mysql_error());
    $rows mysql_num_rows($data);

    //This is the number of results displayed per page
    $page_rows 25;

    //This tells us the page number of our last page
    $last ceil($rows $page_rows);

    //this makes sure the page number isn't below one, or more than our maximum pages
    if ($pagenum 1)
    {
        
    $pagenum 1;
    } elseif (
    $pagenum $last)
    {
        
    $pagenum $last;
    }

    //This sets the range to display in our query
    $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

    {
    ?>
    <p><A href='index.php?page=mainforums'><img src="http://www.runningprofiles.com/images/homeforum.gif" alt="home" border="0"  /></a><A href='index.php?page=post&forum=<?php echo
    $forum?>'><img src="http://www.runningprofiles.com/images/new_post.gif" border="0"  /></a></p>
    <p>users viewing forum = <?php if ($result mysql_query("SELECT * FROM useronline"))
        {
            if (
    mysql_num_rows($result))
            {
                while (
    $row mysql_fetch_array($result))
                {
                    
    $last_active time() - $row['timestamp'];
                    if (
    $last_active 3600)
                    {
                        
    $onlineuser[] = $row['user'];
                    }
                }
            }
        }

        if (isset(
    $onlineuser))
        {
            if (
    count($onlineuser) == 1)
            {
                echo 
    $onlineuser[0];
            }
            else
            {
                for (
    $i 0$i count($onlineuser); $i++)
                {
                    if (
    $i == count($onlineuser) - 1)
                    {
                        echo 
    " and " $onlineuser[$i];
                    }
                    else
                    {
                        echo 
    "  " $onlineuser[$i];
                    }
                }
            }
        }

    ?>

    </p>
    <table width="99%" class='forum'>
      <tr>
        <td><table class='maintable'>

    <tr class='headline'><td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>Topic</td>
      <td width=15%>Topic Starter</td>
    <td width="5%">Replies</td><td width="25%">Last replied time</td></tr>
    <?

        $getthreads 
    "Select * from forumtutorial_posts where parentid='0' and forum = '$forum' ORDER BY important ASC, lastrepliedto DESC $max";


        
    $getthreads2 mysql_query($getthreads) or die("Could not get threads");

        while (
    $getthreads3 mysql_fetch_array($getthreads2))
        {

            
    $getthreads3[title] = strip_tags($getthreads3[title]);

            
    $getthreads3[author] = strip_tags($getthreads3[author]);
            
    $getthreads3[important] = strip_tags($getthreads3[important]);
            
    $important $getthreads3['important'];
    ?>
     <tr <?php if ($important == 1)
            {
                
    $class "mainrow1";
            }
            else
            {
                
    $class "mainrow";
            } 
    ?> class="<? echo $class ?>"><td width="6%" height="39" align="center" valign="middle"><? if ($getthreads3[author] ==
    $puser)
            { 
    ?> <img src="http://www.runningprofiles.com/images/new_posts_icon.gif" alt="My" /> <? }
            else
            { 
    ?> <img src="http://www.runningprofiles.com/images/last_post.gif" alt="My" /> <? ?>
       <td width="4%" align="center" valign="middle"><?php if ($getthreads3['forumlock'] ==
    1)
            {
                echo 
    ' <img src="http://www.runningprofiles.com/images/quick_lock.gif" alt="locked"/>';
            }
            if (
    $getthreads3['important'] == 1)
            {
                echo 
    '<img src="http://www.runningprofiles.com/images/sticky.gif" alt="sticky"/>';
            } 
    ?></td>
    <td width="45%" valign="top"><div align="left"><a href='index.php?page=message&forum=<? echo
    $forum?>&id=<? echo
    $getthreads3[postid?>'><? echo
    $getthreads3[title?></a>  
      
       <?php if ($id == 1)
            {
                include 
    'editforum.php';
            }
            ; 
    ?>
          </div></td>
      <td align="left" valign="middle"><a href='/members/<? echo $getthreads3[author]; ?>'><? echo
    $getthreads3[author?></a></td>
      <td align="center" valign="top"><? echo $getthreads3[numreplies?></td>
      <td valign="top"><? $dbtime $getthreads3['lastrepliedto'];
            
    $time date("F j Y, g:i a"$dbtime);
            echo 
    $time?><br>
      Last post by <b><? echo $getthreads3[lastposter?> </b></td></tr>
    <?
        
    }
    ?>
    </table></td>
      </tr>
    </table>
    <br>


    </a>
    <p>
      <?
        
    echo "<br>";
    }
    echo 
    "<p>";


    // Start links for pages
    $maxpage $totalpages == $totalpages// add this line
    echo "<p align=center>Page $pagenum of $maxpage <br /> "// change this

    // Sets link for previous 25 and return to page 1
    if ($pagenum != 1)
    {
        
    $pageprev = ($pagenum 1);
        echo 
    "<a href=\"" $_SERVER['PHP_SELF'] . "?page=message&id=$id&pagenum=1\"><<</a>&nbsp;&nbsp;";
        echo 
    "<a href=\"" $_SERVER['PHP_SELF'] . "?page=message&id=$id&pagenum=$pageprev\">PREV&nbsp;</a> ";
    }
    else
    {
        echo 
    "";
    }

    // 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&id=$id&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&id=$id&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&id=$id&pagenum=$pagenext\">NEXT&nbsp;</a>&nbsp;&nbsp;";
        echo 
    "<a href=\"" $_SERVER['PHP_SELF'] . "?page=message&id=$id&pagenum=$totalpages\">>></a>&nbsp;&nbsp;";
    }
    ?>
    </p>
    <p></p>
    <table width="14%" border="0" align="left" cellpadding="0" cellspacing="0">
      <tr>
        <td height="33" colspan="2" align="center"><strong>forum key</strong></td>
      </tr>
      <tr>
        <td width="22%" align="center"><img src="http://www.runningprofiles.com/images/quick_lock.gif" alt="locked"/></td>
        <td width="78%">Locked Topic</td>
      </tr>
      <tr>
        <td align="center" valign="middle"><img src="http://www.runningprofiles.com/images/sticky.gif" alt="sticky"/></td>
        <td>Sticky Topic</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table>
    <?php ?>
    and my editforum.php

    PHP Code:
    <?php
          $topicid
    =$_GET['id'];
    if (isset(
    $_POST['edit'])) {
                  if (
    $_POST['deletepost'] == 'deletepost'){
            
    $threadid =  mysql_real_escape_string$_POST['id']);
            
    mysql_query("DELETE FROM forumtutorial_posts WHERE postid='$threadid'"
    or die(
    mysql_error());
    mysql_query("UPDATE `forumtutorial_posts` SET `numreplies`=`numreplies`-'1' WHERE `postid`='$topicid'"
    or die(
    mysql_error()); 
    header"refresh: 0; url=http://www.runningprofiles.com/members/index.php?page=message&forum=general&id=$id");  
        } else {
        
    $threadid =  mysql_real_escape_string$_POST['id']);
        
    $message $_POST['message'];
        echo 
    $message
         
    $query "UPDATE forumtutorial_posts SET  post = '$message' WHERE postid='$threadid' ";
        
    mysql_query($query) or die('Error, query failed');
        
    header"refresh: 0; url=http://www.runningprofiles.com/members/index.php?page=message&forum=general&id=$id");  
        
    }



        


    }else{


    ?>

    <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="CollapsiblePanel1" class="CollapsiblePanel">
      <div class="CollapsiblePanelTab" tabindex="0"> Edit</div>
      <div class="CollapsiblePanelContent">
    <form name='input' action='index.php?page=message&forum=general&id=<? echo $id ?>' method='post'>
        <input type="hidden" name="id" value="<?php echo $getreplies3['postid'?>">
        <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">
    <!--
    var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1", {contentIsOpen:false});
    //-->
          </script>
    also what should i chnage with the header ?

  • #13
    New Coder
    Join Date
    Jul 2008
    Posts
    91
    Thanks
    4
    Thanked 9 Times in 9 Posts
    Ok so heres the final version, ive added a comment where i added code

    Forum.php
    PHP Code:
    <link rel="stylesheet" type="text/css" href="http://www.runningprofiles.com/css/login.css"> 
    <link rel="stylesheet" type="text/css" href="http://www.runningprofiles.com/members/include/style.css"> 


    <?php 
    require_once '../settings.php'
    include 
    "connect.php"//mysql db connection here 
    $id $_SESSION['user_id']; 
    $puser get_username($id); 

    $timestamp time(); 
    $timeout $timestamp 180
    $username get_username($_SESSION['user_id']); 
    function 
    selfURL() 

        
    $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" ""
        
    $protocol strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/") . $s
        
    $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":" $_SERVER["SERVER_PORT"]); 
        return 
    $protocol "://" $_SERVER['SERVER_NAME'] . $port $_SERVER['REQUEST_URI']; 

    function 
    strleft($s1$s2

        return 
    substr($s10strpos($s1$s2)); 

    $filename = (selfURL()); 
    //Insert User 
    $insert mysql_query("REPLACE INTO `useronline` SET `timestamp`='$timestamp', `ip`='" 
        
    $_SERVER['REMOTE_ADDR'] . "', `file`='$filename',`user`='$username',`user_id`='" 
        
    $_SESSION['user_id'] . "'") or die(mysql_error()); 

    ?> 
    <?php 

    //look to see if the forum is currently locked 
    $sQry "SELECT `locked` FROM forum_lock LIMIT 1"
    $obQry mysql_query($sQry) or die(sprintf("Could not query forums (%d): %s"
        
    mysql_errno(), mysql_error())); 
    $record mysql_fetch_array($obQry); 
    if (isset(
    $record['locked']) && $record['locked']) 

        
    //error message 
        
    die("Sorry, the forums are currently locked."); 

    else 

    //if ok carry on viewing page 

    //This checks to see if there is a page number. If not, it will set it to page 1 
    if (!(isset($pagenum))) 

        
    $pagenum 1


    //Here we count the number of results 
    //Edit $data to be your query 
    $forum $_GET['forum']; 
    $data mysql_query("Select * from forumtutorial_posts where parentid='0' AND forum = '$forum' ORDER BY important, lastrepliedto") or 
        die(
    mysql_error()); 
    $rows mysql_num_rows($data); 

    //This is the number of results displayed per page 
    $page_rows 25

    //This tells us the page number of our last page 
    $last ceil($rows $page_rows); 

    //this makes sure the page number isn't below one, or more than our maximum pages 
    if ($pagenum 1

        
    $pagenum 1
    } elseif (
    $pagenum $last

        
    $pagenum $last


    //This sets the range to display in our query 
    $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 


    ?> 
    <p><A href='index.php?page=mainforums'><img src="http://www.runningprofiles.com/images/homeforum.gif" alt="home" border="0"  /></a><A href='index.php?page=post&forum=<?php echo 
    $forum?>'><img src="http://www.runningprofiles.com/images/new_post.gif" border="0"  /></a></p> 
    <p>users viewing forum = <?php if ($result mysql_query("SELECT * FROM useronline")) 
        { 
            if (
    mysql_num_rows($result)) 
            { 
                while (
    $row mysql_fetch_array($result)) 
                { 
                    
    $last_active time() - $row['timestamp']; 
                    if (
    $last_active 3600
                    { 
                        
    $onlineuser[] = $row['user']; 
                    } 
                } 
            } 
        } 

        if (isset(
    $onlineuser)) 
        { 
            if (
    count($onlineuser) == 1
            { 
                echo 
    $onlineuser[0]; 
            } 
            else 
            { 
                for (
    $i 0$i count($onlineuser); $i++) 
                { 
                    if (
    $i == count($onlineuser) - 1
                    { 
                        echo 
    " and " $onlineuser[$i]; 
                    } 
                    else 
                    { 
                        echo 
    "  " $onlineuser[$i]; 
                    } 
                } 
            } 
        } 

    ?> 

    </p> 
    <table width="99%" class='forum'> 
      <tr> 
        <td><table class='maintable'> 

    <tr class='headline'><td>&nbsp;</td> 
      <td>&nbsp;</td> 
      <td>Topic</td> 
      <td width=15%>Topic Starter</td> 
    <td width="5%">Replies</td><td width="25%">Last replied time</td></tr> 
    <? 

        $getthreads 
    "Select * from forumtutorial_posts where parentid='0' and forum = '$forum' ORDER BY important ASC, lastrepliedto DESC $max"


        
    $getthreads2 mysql_query($getthreads) or die("Could not get threads"); 

        while (
    $getthreads3 mysql_fetch_array($getthreads2)) 
        { 

            
    $getthreads3[title] = strip_tags($getthreads3[title]); 

            
    $getthreads3[author] = strip_tags($getthreads3[author]); 
            
    $getthreads3[important] = strip_tags($getthreads3[important]); 
            
    $important $getthreads3['important']; 
    ?> 
     <tr <?php if ($important == 1
            { 
                
    $class "mainrow1"
            } 
            else 
            { 
                
    $class "mainrow"
            } 
    ?> class="<? echo $class ?>"><td width="6%" height="39" align="center" valign="middle"><? if ($getthreads3[author] == 
    $puser
            { 
    ?> <img src="http://www.runningprofiles.com/images/new_posts_icon.gif" alt="My" /> <? 
            else 
            { 
    ?> <img src="http://www.runningprofiles.com/images/last_post.gif" alt="My" /> <? ?> 
       <td width="4%" align="center" valign="middle"><?php if ($getthreads3['forumlock'] == 
    1
            { 
                echo 
    ' <img src="http://www.runningprofiles.com/images/quick_lock.gif" alt="locked"/>'
            } 
            if (
    $getthreads3['important'] == 1
            { 
                echo 
    '<img src="http://www.runningprofiles.com/images/sticky.gif" alt="sticky"/>'
            } 
    ?></td> 
    <td width="45%" valign="top"><div align="left"><a href='index.php?page=message&forum=<? echo 
    $forum?>&id=<? echo 
    $getthreads3[postid?>'><? echo 
    $getthreads3[title?></a>   
       
       <?php if ($id == 1
            { 
    //We need to add a Little variable that will automatically increase so that
    //Each div (container) in the editforum.php script is unique:
    $CONT_ID 1;
                include 
    'editforum.php'
    //Now increase it:
    $CONT_ID++;
            } 
            ; 
    ?> 
          </div></td> 
      <td align="left" valign="middle"><a href='/members/<? echo $getthreads3[author]; ?>'><? echo 
    $getthreads3[author?></a></td> 
      <td align="center" valign="top"><? echo $getthreads3[numreplies?></td> 
      <td valign="top"><? $dbtime $getthreads3['lastrepliedto']; 
            
    $time date("F j Y, g:i a"$dbtime); 
            echo 
    $time?><br> 
      Last post by <b><? echo $getthreads3[lastposter?> </b></td></tr> 
    <? 
        

    ?> 
    </table></td> 
      </tr> 
    </table> 
    <br> 


    </a> 
    <p> 
      <? 
        
    echo "<br>"

    echo 
    "<p>"


    // Start links for pages 
    $maxpage $totalpages == $totalpages// add this line 
    echo "<p align=center>Page $pagenum of $maxpage <br /> "// change this 

    // Sets link for previous 25 and return to page 1 
    if ($pagenum != 1

        
    $pageprev = ($pagenum 1); 
        echo 
    "<a href=\"" $_SERVER['PHP_SELF'] . "?page=message&id=$id&pagenum=1\"><<</a>&nbsp;&nbsp;"
        echo 
    "<a href=\"" $_SERVER['PHP_SELF'] . "?page=message&id=$id&pagenum=$pageprev\">PREV&nbsp;</a> "

    else 

        echo 
    ""


    // 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&id=$id&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&id=$id&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&id=$id&pagenum=$pagenext\">NEXT&nbsp;</a>&nbsp;&nbsp;"
        echo 
    "<a href=\"" $_SERVER['PHP_SELF'] . "?page=message&id=$id&pagenum=$totalpages\">>></a>&nbsp;&nbsp;"

    ?> 
    </p> 
    <p></p> 
    <table width="14%" border="0" align="left" cellpadding="0" cellspacing="0"> 
      <tr> 
        <td height="33" colspan="2" align="center"><strong>forum key</strong></td> 
      </tr> 
      <tr> 
        <td width="22%" align="center"><img src="http://www.runningprofiles.com/images/quick_lock.gif" alt="locked"/></td> 
        <td width="78%">Locked Topic</td> 
      </tr> 
      <tr> 
        <td align="center" valign="middle"><img src="http://www.runningprofiles.com/images/sticky.gif" alt="sticky"/></td> 
        <td>Sticky Topic</td> 
      </tr> 
      <tr> 
        <td>&nbsp;</td> 
        <td>&nbsp;</td> 
      </tr> 
    </table> 
    <?php ?>
    Editforum.php
    PHP Code:
    <?php 
          $topicid
    =$_GET['id']; 
    if (isset(
    $_POST['edit'])) { 
                  if (
    $_POST['deletepost'] == 'deletepost'){ 
            
    $threadid =  mysql_real_escape_string$_POST['id']); 
            
    mysql_query("DELETE FROM forumtutorial_posts WHERE postid='$threadid'")  
    or die(
    mysql_error()); 
    mysql_query("UPDATE `forumtutorial_posts` SET `numreplies`=`numreplies`-'1' WHERE `postid`='$topicid'")  
    or die(
    mysql_error());  
    header"refresh: 0; url=http://www.runningprofiles.com/members/index.php?page=message&forum=general&id=$id");   
        } else { 
        
    $threadid =  mysql_real_escape_string$_POST['id']); 
        
    $message $_POST['message']; 
        echo 
    $message;  
         
    $query "UPDATE forumtutorial_posts SET  post = '$message' WHERE postid='$threadid' "
        
    mysql_query($query) or die('Error, query failed'); 
        
    header"refresh: 0; url=http://www.runningprofiles.com/members/index.php?page=message&forum=general&id=$id");   
         




         


    }else{ 


    ?> 

    <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='index.php?page=message&forum=general&id=<? echo $id ?>' method='post'> 
        <input type="hidden" name="id" value="<?php echo $getreplies3['postid'?>"> 
        <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>
    The mod i done should make it work, just pm me or post if it doesnt. and thank me if it does

    As for the HTML, take a look at your source, you dont have a doctype and you have a table where the head should be...

    Scoop_987
    Last edited by scoop_987; 07-26-2008 at 05:09 PM.

  • #14
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    sadly the code seems to keep the 1st dropdown going still

  • #15
    New Coder
    Join Date
    Jul 2008
    Posts
    91
    Thanks
    4
    Thanked 9 Times in 9 Posts
    Make sure you have modified and uploaded (or copied) BOTH files. I have modified both of them.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •