Jump to content

ajax pull down table acting wired


runnerjp

Recommended Posts

on my forum i have a pull down ajax table

 

it works like soon my forum page i have

 

<?php if ($id == 1)
        {
            include 'editforum.php';
        }
        ; ?>

 

editforum.php has this

 

<?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="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=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>

 

both the file in css are...

 

 

@charset "UTF-8";

/* SpryCollapsiblePanel.css - Revision: Spry Preview Release 1.4 */

/* Copyright (c) 2006. Adobe Systems Incorporated. All rights reserved. */

/* This is the selector for the main CollapsiblePanel container. For our
* default style, the CollapsiblePanel is responsible for drawing the borders
* around the widget.
*
* If you want to constrain the width of the CollapsiblePanel widget, set a width on
* the CollapsiblePanel container. By default, our CollapsiblePanel expands horizontally to fill
* up available space.
*
* The name of the class ("CollapsiblePanel") used in this selector is not necessary
* to make the widget function. You can use any class name you want to style the
* CollapsiblePanel container.
*/
.CollapsiblePanel {
margin: 0px;
padding: 0px;
float:right;
}

/* This is the selector for the CollapsiblePanelTab. This container houses
* the title for the panel. This is also the container that the user clicks
* on to open or close the panel.
*
* The name of the class ("CollapsiblePanelTab") used in this selector is not necessary
* to make the widget function. You can use any class name you want to style an
* CollapsiblePanel panel tab container.
*/
.CollapsiblePanelTab {
font: bold 0.7em sans-serif;
background-color: #DDD;
border-bottom: solid 1px #CCC;
margin: 0px;
padding: 2px;
cursor: pointer;
-moz-user-select: none;
-khtml-user-select: none;
width: 20px;
float:right;
}

/* This is the selector for a CollapsiblePanel's Content area. It's important to note that
* you should never put any padding on the content area element if you plan to
* use the CollapsiblePanel's open/close animations. Placing a non-zero padding on the content
* element can cause the CollapsiblePanel to abruptly grow in height while the panels animate.
*
* The name of the class ("CollapsiblePanelContent") used in this selector is not necessary
* to make the widget function. You can use any class name you want to style a
* CollapsiblePanel content container.
*/
.CollapsiblePanelContent {
margin: 0px;
padding: 0px;
float:right;
}

/* An anchor tag can be used inside of a CollapsiblePanelTab so that the
* keyboard focus ring appears *inside* the tab instead of around the tab.
* This is an example of how to make the text within the anchor tag look
* like non-anchor (normal) text.
*/
.CollapsiblePanelTab a {
color: black;
text-decoration: none;
float:right;
}

/* This is an example of how to change the appearance of the panel tab that is
* currently open. The class "CollapsiblePanelOpen" is programatically added and removed
* from panels as the user clicks on the tabs within the CollapsiblePanel.
*/
.CollapsiblePanelOpen .CollapsiblePanelTab {
background-color: #EEE;
float:right;
}

/* This is an example of how to change the appearance of the panel tab as the
* mouse hovers over it. The class "CollapsiblePanelTabHover" is programatically added
* and removed from panel tab containers as the mouse enters and exits the tab container.
*/
.CollapsiblePanelTabHover,  .CollapsiblePanelOpen .CollapsiblePanelTabHover {
background-color: #CCC;
float:right;
}

/* This is an example of how to change the appearance of all the panel tabs when the
* CollapsiblePanel has focus. The "CollapsiblePanelFocused" class is programatically added and removed
* whenever the CollapsiblePanel gains or loses keyboard focus.
*/
.CollapsiblePanelFocused .CollapsiblePanelTab {
background-color: #3399FF;
float:right;
}

 

and

 

var Spry;
if (!Spry) Spry = {};
if (!Spry.Widget) Spry.Widget = {};

Spry.Widget.CollapsiblePanel = function(element, opts)
{
this.init(element);

Spry.Widget.CollapsiblePanel.setOptions(this, opts);

this.attachBehaviors();
};

Spry.Widget.CollapsiblePanel.prototype.init = function(element)
{
this.element = this.getElement(element);
this.focusElement = null;
this.hoverClass = "CollapsiblePanelTabHover";
this.openClass = "CollapsiblePanelOpen";
this.closedClass = "CollapsiblePanelClosed";
this.focusedClass = "CollapsiblePanelFocused";
this.enableAnimation = true;
this.enableKeyboardNavigation = true;
this.animator = null;
this.hasFocus = false;
this.contentIsOpen = true;
};

Spry.Widget.CollapsiblePanel.prototype.getElement = function(ele)
{
if (ele && typeof ele == "string")
	return document.getElementById(ele);
return ele;
};

Spry.Widget.CollapsiblePanel.prototype.addClassName = function(ele, className)
{
if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) != -1))
	return;
ele.className += (ele.className ? " " : "") + className;
};

Spry.Widget.CollapsiblePanel.prototype.removeClassName = function(ele, className)
{
if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) == -1))
	return;
ele.className = ele.className.replace(new RegExp("\\s*\\b" + className + "\\b", "g"), "");
};

Spry.Widget.CollapsiblePanel.prototype.hasClassName = function(ele, className)
{
if (!ele || !className || !ele.className || ele.className.search(new RegExp("\\b" + className + "\\b")) == -1)
	return false;
return true;
};

Spry.Widget.CollapsiblePanel.prototype.setDisplay = function(ele, display)
{
if( ele )
	ele.style.display = display;
};

Spry.Widget.CollapsiblePanel.setOptions = function(obj, optionsObj, ignoreUndefinedProps)
{
if (!optionsObj)
	return;
for (var optionName in optionsObj)
{
	if (ignoreUndefinedProps && optionsObj[optionName] == undefined)
		continue;
	obj[optionName] = optionsObj[optionName];
}
};

Spry.Widget.CollapsiblePanel.prototype.onTabMouseOver = function()
{
this.addClassName(this.getTab(), this.hoverClass);
};

Spry.Widget.CollapsiblePanel.prototype.onTabMouseOut = function()
{
this.removeClassName(this.getTab(), this.hoverClass);
};

Spry.Widget.CollapsiblePanel.prototype.open = function()
{
this.contentIsOpen = true;
if (this.enableAnimation)
{
	if (this.animator)
		this.animator.stop();
	this.animator = new Spry.Widget.CollapsiblePanel.PanelAnimator(this, true);
	this.animator.start();
}
else
	this.setDisplay(this.getContent(), "block");

this.removeClassName(this.element, this.closedClass);
this.addClassName(this.element, this.openClass);
};

Spry.Widget.CollapsiblePanel.prototype.close = function()
{
this.contentIsOpen = false;
if (this.enableAnimation)
{
	if (this.animator)
		this.animator.stop();
	this.animator = new Spry.Widget.CollapsiblePanel.PanelAnimator(this, false);
	this.animator.start();
}
else
	this.setDisplay(this.getContent(), "none");

this.removeClassName(this.element, this.openClass);
this.addClassName(this.element, this.closedClass);
};

Spry.Widget.CollapsiblePanel.prototype.onTabClick = function()
{
if (this.isOpen())
	this.close();
else
	this.open();
this.focus();
};

Spry.Widget.CollapsiblePanel.prototype.onFocus = function(e)
{
this.hasFocus = true;
this.addClassName(this.element, this.focusedClass);
};

Spry.Widget.CollapsiblePanel.prototype.onBlur = function(e)
{
this.hasFocus = false;
this.removeClassName(this.element, this.focusedClass);
};

Spry.Widget.CollapsiblePanel.ENTER_KEY = 13;
Spry.Widget.CollapsiblePanel.SPACE_KEY = 32;

Spry.Widget.CollapsiblePanel.prototype.onKeyDown = function(e)
{
var key = e.keyCode;
if (!this.hasFocus || (key != Spry.Widget.CollapsiblePanel.ENTER_KEY && key != Spry.Widget.CollapsiblePanel.SPACE_KEY))
	return true;

if (this.isOpen())
	this.close();
else
	this.open();

if (e.stopPropagation)
	e.stopPropagation();
if (e.preventDefault)
	e.preventDefault();

return false;
};

Spry.Widget.CollapsiblePanel.prototype.attachPanelHandlers = function()
{
var tab = this.getTab();
if (!tab)
	return;

var self = this;
Spry.Widget.CollapsiblePanel.addEventListener(tab, "click", function(e) { return self.onTabClick(); }, false);
Spry.Widget.CollapsiblePanel.addEventListener(tab, "mouseover", function(e) { return self.onTabMouseOver(); }, false);
Spry.Widget.CollapsiblePanel.addEventListener(tab, "mouseout", function(e) { return self.onTabMouseOut(); }, false);

if (this.enableKeyboardNavigation)
{
	// XXX: IE doesn't allow the setting of tabindex dynamically. This means we can't
	// rely on adding the tabindex attribute if it is missing to enable keyboard navigation
	// by default.

	// Find the first element within the tab container that has a tabindex or the first
	// anchor tag.

	var tabIndexEle = null;
	var tabAnchorEle = null;

	this.preorderTraversal(tab, function(node) {
		if (node.nodeType == 1 /* NODE.ELEMENT_NODE */)
		{
			var tabIndexAttr = tab.attributes.getNamedItem("tabindex");
			if (tabIndexAttr)
			{
				tabIndexEle = node;
				return true;
			}
			if (!tabAnchorEle && node.nodeName.toLowerCase() == "a")
				tabAnchorEle = node;
		}
		return false;
	});

	if (tabIndexEle)
		this.focusElement = tabIndexEle;
	else if (tabAnchorEle)
		this.focusElement = tabAnchorEle;

	if (this.focusElement)
	{
		Spry.Widget.CollapsiblePanel.addEventListener(this.focusElement, "focus", function(e) { return self.onFocus(e); }, false);
		Spry.Widget.CollapsiblePanel.addEventListener(this.focusElement, "blur", function(e) { return self.onBlur(e); }, false);
		Spry.Widget.CollapsiblePanel.addEventListener(this.focusElement, "keydown", function(e) { return self.onKeyDown(e); }, false);
	}
}
};

Spry.Widget.CollapsiblePanel.addEventListener = function(element, eventType, handler, capture)
{
try
{
	if (element.addEventListener)
		element.addEventListener(eventType, handler, capture);
	else if (element.attachEvent)
		element.attachEvent("on" + eventType, handler);
}
catch (e) {}
};

Spry.Widget.CollapsiblePanel.prototype.preorderTraversal = function(root, func)
{
var stopTraversal = false;
if (root)
{
	stopTraversal = func(root);
	if (root.hasChildNodes())
	{
		var child = root.firstChild;
		while (!stopTraversal && child)
		{
			stopTraversal = this.preorderTraversal(child, func);
			try { child = child.nextSibling; } catch (e) { child = null; }
		}
	}
}
return stopTraversal;
};

Spry.Widget.CollapsiblePanel.prototype.attachBehaviors = function()
{
var panel = this.element;
var tab = this.getTab();
var content = this.getContent();

if (this.contentIsOpen || this.hasClassName(panel, this.openClass))
{
	this.removeClassName(panel, this.closedClass);
	this.setDisplay(content, "block");
	this.contentIsOpen = true;
}
else
{
	this.removeClassName(panel, this.openClass);
	this.addClassName(panel, this.closedClass);
	this.setDisplay(content, "none");
	this.contentIsOpen = false;
}

this.attachPanelHandlers();
};

Spry.Widget.CollapsiblePanel.prototype.getTab = function()
{
return this.getElementChildren(this.element)[0];
};

Spry.Widget.CollapsiblePanel.prototype.getContent = function()
{
return this.getElementChildren(this.element)[1];
};

Spry.Widget.CollapsiblePanel.prototype.isOpen = function()
{
return this.contentIsOpen;
};

Spry.Widget.CollapsiblePanel.prototype.getElementChildren = function(element)
{
var children = [];
var child = element.firstChild;
while (child)
{
	if (child.nodeType == 1 /* Node.ELEMENT_NODE */)
		children.push(child);
	child = child.nextSibling;
}
return children;
};

Spry.Widget.CollapsiblePanel.prototype.focus = function()
{
if (this.focusElement && this.focusElement.focus)
	this.focusElement.focus();
};

/////////////////////////////////////////////////////

Spry.Widget.CollapsiblePanel.PanelAnimator = function(panel, doOpen, opts)
{
this.timer = null;
this.interval = 0;
this.stepCount = 0;

this.fps = 0;
this.steps = 10;
this.duration = 500;
this.onComplete = null;

this.panel = panel;
this.content = panel.getContent();
this.panelData = [];
this.doOpen = doOpen;

Spry.Widget.CollapsiblePanel.setOptions(this, opts);


// If caller specified speed in terms of frames per second,
// convert them into steps.

if (this.fps > 0)
{
	this.interval = Math.floor(1000 / this.fps);
	this.steps = parseInt((this.duration + (this.interval - 1)) / this.interval);
}
else if (this.steps > 0)
	this.interval = this.duration / this.steps;

var c = this.content;

var curHeight = c.offsetHeight ? c.offsetHeight : 0;

if (doOpen && c.style.display == "none")
	this.fromHeight = 0;
else
	this.fromHeight = curHeight;

if (!doOpen)
	this.toHeight = 0;
else
{
	if (c.style.display == "none")
	{
		// The content area is not displayed so in order to calculate the extent
		// of the content inside it, we have to set its display to block.

		c.style.visibility = "hidden";
		c.style.display = "block";
	}

	// Unfortunately in Mozilla/Firefox, fetching the offsetHeight seems to cause
	// the browser to synchronously re-layout and re-display content on the page,
	// so we see a brief flash of content that is *after* the panel being positioned
	// where it should when the panel is fully expanded. To get around this, we
	// temporarily position the content area of the panel absolutely off-screen.
	// This has the effect of taking the content out-of-flow, so nothing shifts around.

	// var oldPos = c.style.position;
	// var oldLeft = c.style.left;
	// c.style.position = "absolute";
	// c.style.left = "-2000em";

	// Clear the height property so we can calculate
	// the full height of the content we are going to show.
	c.style.height = "";
	this.toHeight = c.offsetHeight;

	// Now restore the position and offset to what it was!
	// c.style.position = oldPos;
	// c.style.left = oldLeft;
}

this.increment = (this.toHeight - this.fromHeight) / this.steps;
this.overflow = c.style.overflow;

c.style.height = this.fromHeight + "px";
c.style.visibility = "visible";
c.style.overflow = "hidden";
c.style.display = "block";
};

Spry.Widget.CollapsiblePanel.PanelAnimator.prototype.start = function()
{
var self = this;
this.timer = setTimeout(function() { self.stepAnimation(); }, this.interval);
};

Spry.Widget.CollapsiblePanel.PanelAnimator.prototype.stop = function()
{
if (this.timer)
{
	clearTimeout(this.timer);

	// If we're killing the timer, restore the overflow
	// properties on the panels we were animating!

	if (this.stepCount < this.steps)
		this.content.style.overflow = this.overflow;
}

this.timer = null;
};

Spry.Widget.CollapsiblePanel.PanelAnimator.prototype.stepAnimation = function()
{
++this.stepCount;

this.animate();

if (this.stepCount < this.steps)
	this.start();
else if (this.onComplete)
	this.onComplete();
};

Spry.Widget.CollapsiblePanel.PanelAnimator.prototype.animate = function()
{
if (this.stepCount >= this.steps)
{
	if (!this.doOpen)
		this.content.style.display = "none";
	this.content.style.overflow = this.overflow;
	this.content.style.height = this.toHeight + "px";
}
else
{
	this.fromHeight += this.increment;
	this.content.style.height = this.fromHeight + "px";
}
};

 

but for some reason

 

<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($s1, 0, strpos($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> </td>
  <td> </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 == 0 ? 1 : $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>  ";
    echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=message&id=$id&pagenum=$pageprev\">PREV </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 </a>  ";
    echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=message&id=$id&pagenum=$totalpages\">>></a>  ";
}
?>
</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> </td>
    <td> </td>
  </tr>
</table>
<?php } ?> 

the code above has the first post shown to have a closed bx but all the others are open and i cant close them...how comes...i hope this all makes sence

 

Link to comment
Share on other sites

i thought i best explain a little clearer again lol

 

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

 

ok so below is my forum script in full

 

<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($s1, 0, strpos($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> </td>
  <td> </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 == 0 ? 1 : $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>  ";
    echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=message&id=$id&pagenum=$pageprev\">PREV </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 </a>  ";
    echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=message&id=$id&pagenum=$totalpages\">>></a>  ";
}
?>
</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> </td>
    <td> </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 if ($id == 1)
        {
            include 'editforum.php';
        }
        ; ?>

will show this page

 

<?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

 

error.jpg

 

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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