Wiki Button issues.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ThatPerson
Forum Commoner
Posts: 50
Joined: Wed Aug 03, 2011 1:57 am

Wiki Button issues.

Post by ThatPerson »

I am working on a Wiki which has all the articles in buttons on the left, yet unfortunately the code which makes the button is only showing 1. In the Database I added a new entry, which works on its own, however the code will not enter a new button. The code is:

Code: Select all

include("database.php");
ob_start();
$pages = mysql_query("select max(ID) from swarm_wiki");

echo <<<END
	<head>
		<title>Crimson Swarm</title>
	</head>
END;
echo <<<end
	<div style = "overflow:scroll;height:100%;width:200px;">
end;
$p = 0;
for ($i = 3; $i <= $pages; $i++) {
	$p = $p+1;
	${note.$p."title"} = mysql_fetch_object(mysql_query("select Name from swarm_wiki where ID = '$p'")) ->Name;
	${note.$p."text"} = mysql_fetch_object(mysql_query("select Text from swarm_wiki where ID = '$p'")) ->Text;
	$title = ${note.$p."title"};

	$text = ${note.$p."text"};
	$pos = 50*($p-1);
	$submit = "Submit".$p;
echo <<<END
	<div style = "height:50px;width:100%;position:inherit;left:0px;top:$pos;background-color:#3399FF;">
		<INPUT style = "position:inherit;height:100%;width:100%;background-color:#3399FF;top:0px;left:0px;" value = "$title" name = "$submit" type="Submit">
		<div style = "position:inherit;height:50%;left:0px;top:50%;width:100%;">
			<p>$desc</p>
		</div>
	</div>
END;
}
echo "</div>";
The Database is:

[text]Full texts ID Name describe Text In
1 Home The homepage echo "<html><head></head><body><p>Hello, welcome t... 1
2 Places To Go echo "<html> <head> </head> <body> <i3>On The Crim... 1[/text]

(Not sure how well that came out)

And the output of it is:

[text] <head>
<title>Crimson Swarm</title>
</head>
<body>
<div style = "overflow:scroll;height:100%;width:200px;">
<div style = "height:50px;width:100%;position:inherit;left:0px;top:0;background-color:#3399FF;">
<INPUT style = "position:inherit;height:100%;width:100%;background-color:#3399FF;top:0px;left:0px;" value = "Home" name = "Submit1" type="Submit">
<div style = "position:inherit;height:50%;left:0px;top:50%;width:100%;">
<p></p>
</div>
</div>
</div>
</div>
<div style = 'left:210px;right:0px;height:100%;top:0px;bottom:0px;position:absolute;'>
<h1>Crimson Wiki</h1>
<div style="overflow:scroll;top:150px;position:absolute;left:0px;bottom:0px;right:0px">
<html>
<head>
</head>
<body>
<p>Hello, </p>
</body>
</html>
<div style="height:150px;width:100%;top:0px;left:0px;">
<h2>Home</h2>
</div>
<div style="top:150px;left:0px;width:100%;">
</div>
</div>[/text]
ThatPerson
Forum Commoner
Posts: 50
Joined: Wed Aug 03, 2011 1:57 am

Re: Wiki Button issues.

Post by ThatPerson »

Right, I fixed that issue, however now I am having problems getting a for loop to run. The full wiki code is:

Code: Select all

<?php
include("database.php");
ob_start();
$pagetest = mysql_query("select count(*) as count from swarm_wiki");
$pages = mysql_fetch_object($pagetest)->count;
var_dump($pages);
echo <<<END
	<head>
		<title>Crimson Swarm</title>
	</head>
END;
echo <<<end
	<div style = "overflow:scroll;height:100%;width:200px;">
end;
$p = 0;
$times = 5-$pagetest;
for ($i = $times; $i <= $pagetest; $i++) {
	$p = $p+1;
	var_dump($p);
	${note.$p."title"} = mysql_fetch_object(mysql_query("select Name from swarm_wiki where ID = '$p'")) ->Name;
	${note.$p."text"} = mysql_fetch_object(mysql_query("select Text from swarm_wiki where ID = '$p'")) ->Text;
	$title = ${note.$p."title"};

	$text = ${note.$p."text"};
	$pos = 50*($p-1);
	$submit = "Submit".$p;
	var_dump($submit);
echo <<<END
	<div style = "height:50px;width:100%;position:inherit;left:0px;top:$pos;background-color:#3399FF;">
		<INPUT style = "position:inherit;height:100%;width:100%;background-color:#3399FF;top:0px;left:0px;" value = "$title" name = "$submit" type="Submit">
		<div style = "position:inherit;height:50%;left:0px;top:50%;width:100%;">
			<p>$desc</p>
		</div>
	</div>
END;
}


$a = 0;
for ($i = $times; $i <= $pagetest; $i++) {

	$a = $a+1;
	$submit = "Submit".$a;

	if (isset($_POST[$submit])) {
		setcookie("page",$a,time()+60*60);
echo <<<end
	<head>
		<meta HTTP-EQUIV="REFRESH" content="0; url='index.php'">
	</head>
end;
}
}

echo "</div>";
echo "</div>";
echo "<div style = 'left:210px;right:0px;height:100%;top:0px;bottom:0px;position:absolute;'>";
echo "<h1>Crimson Wiki</h1>";
echo <<<END
<div style="overflow:scroll;top:150px;position:absolute;left:0px;bottom:0px;right:0px">
END;
if (!$_COOKIE['page']) {
$text = eval($note1text);
$title = $note1title;

echo <<<END
<div style="height:150px;width:100%;top:0px;left:0px;">
<h2>$title</h2>
</div>

<div style="top:150px;left:0px;width:100%;">
$text
</div>
END;
} else {
$p = $_COOKIE['page'];
$text = eval('${note.$p."text"}');
$title = ${note.$p."title"};

echo <<<END
<div style="height:150px;left:200px;right:0px;position:inherit;top:0px;left:0px;">
<h2>$title</h2>
</div>

<div style="top:150px;left:0px;width:100%;position:inherit;">
$text
</div>
END;
}
echo "</div>";
?>
And this for loop:

Code: Select all

$a = 0;
for ($i = $times; $i <= $pagetest; $i++) {
var_dump($a);
	$a = $a+1;
	$submit = "Submit".$a;

	if (isset($_POST[$submit])) {
		setcookie("page",$a,time()+60*60);
echo <<<end
	<head>
		<meta HTTP-EQUIV="REFRESH" content="0; url='index.php'">
	</head>
end;
}
}
And that returns NOTHING.

When I click the buttons, nothing.
Any ideas?
Post Reply