Page 1 of 1

Layout issue

Posted: Fri Aug 18, 2017 4:16 pm
by Kesstryl
I'm trying to fix the tables in the Clan Mod for the Dragon Knight updated game that I've been working on, and for this one page the table rows are not going below each other. Instead they are making a long row which will not be sustainable on a live game. Here's a screenshot of what I'm talking about:

Image

and here is the code that goes with the table (not written by me, but I am trying to fix it):

Code: Select all

function clanjoin(){ //Join a clan
 
 	global $userrow;
	
	$check = protectcsfr();
	$link = opendb();
    $clanquery = doquery($link, "SELECT * FROM {{table}} WHERE id='".$userrow["clan"]."' LIMIT 1", "clan");
    $clanrow = mysqli_fetch_array($clanquery);
    $clanname = $clanrow["name"]; 
	$clanid = $clanrow["id"];

if($userrow["clan"] != "0" && $userrow["clanjoin"] == "0") { header("Location: index.php?do=clan"); die();	}

if(isset($_POST['Join'])){
	$_POST['Join'] = protect($_POST['Join']);
	$clanid = protect($_POST['clanid']);
	$token = protect($_POST['token']);
	
	if ($_SESSION['token'] != $token) { die("Invalid request");}
	
	doquery($link, "UPDATE {{table}} SET clan='$clanid', clanjoin='1' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
	 unset($_SESSION['token']);
	header('Location: index.php?do=clanjoin'); die();
}
if(isset($_POST['Cancel'])){
	$_POST['Cancel'] = protect($_POST['Cancel']);
	$token = protect($_POST['token']);
	
	if ($_SESSION['token'] != $token) { die("Invalid request");}
	doquery($link, "UPDATE {{table}} SET clan='0',clanjoin='0' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
	$page = "You left the clan!<br /><br /><a href=\"index.php?do=clan\">Back to Clans List.</a><br /><a href=\"index.php\">Back to Town</a><br />";
	unset($_SESSION['token']);
}

$page = "You are not yet a member of any of the clan's. Here is a list of all the clan's in the game. Please choose one to join.<br /><br />";

$membersquery= doquery($link, "SELECT clan FROM {{table}} WHERE id='".$userrow['id']."' LIMIT 1", "users");
$members= mysqli_num_rows($membersquery);

	if($userrow["clan"] > 0){
	$page = "Application pending";
	$page .="<br /><br /><form action=\"index.php?do=clanmembers\" method=\"post\"><input type=\"hidden\" name=\"token\" value=\"$token\" /><input type=\"submit\" name=\"Cancel\" value=\"Cancel Application\"></form><br />";
	
	}else{

	$page .= "<table><tr class=\"title\"><td>Clan's name</td><td>Members</td><td>Message to joiners</td><td>Join</td></tr>";

	$clans = doquery($link, "SELECT * FROM {{table}}", "clan");
	while($list = mysqli_fetch_array($clans)) {
		$id = $list["id"];
		$name = $list['name'];
		$message = $list['message'];
		
		$token = formtoken();
		$page .="<tr class=\"nimekiri\"><td>$name</td><td>$members</td><td>$message</td><td><form action=\"index.php?do=clanjoin\" method=\"post\"><input type=\"hidden\" name=\"token\" value=\"$token\" /><input type=\"submit\" name=\"Join\" value=\"Join\"> <input type=\"hidden\" name=\"clanid\" value=\"".$list["id"]."\></form></td></tr>";
		}
	}
	
$page .= "</br>";		
$page .="<tr class=\"nimekiri\"><td colspan=\"4\" align=\"center\"><a href=\"index.php?do=clancreate\">Found a NEW clan!</a></td></tr></table><br /><br />";
$page .="<a href=\"index.php\">Back to Town</a><br />";


    $page2["clancontent"] = $page;
	$display = gettemplate("clan");
    $display = parsetemplate($display, $page2);
	display($display,"Clans");
}
This is the template code:

Code: Select all

$template = <<<THEVERYENDOFYOU
<br /><br /><center>
<table class="clanmenu" width="90%" height="5">
<tr><td align="center">
<a href="index.php?do=clan">Clan</a> | <a href="index.php?do=clanmembers"> Members </a>| <a href="index.php?do=clanleader"> Leader's Office</a>| <a href="index.php">Back to Town</a>
</td></tr></table>
<br />
<div class="clan" >
<center>
{{clancontent}}
<br /></center>
</div>
THEVERYENDOFYOU;
The CSS classes from the CSS page this code calls are these:

Code: Select all

.clan {
  border: solid 1px black;
  background-color: #BABAA9;
  padding: 5px;
  margin: 3px;
}
.clanmenu {
  border: solid 1px black;
  background-color: #bbbb99;
}
.nimekiri {
  border: solid 1px black;
  background-color: #FFFFFF;
}

Re: Layout issue

Posted: Fri Aug 18, 2017 8:19 pm
by hallsofvallhalla
thats an odd one. Click on the row that is not moving down in Chrome and hot inspect, see if all the table code is there and proper.

Re: Layout issue

Posted: Fri Aug 18, 2017 9:28 pm
by Kesstryl
It appears to be the form button inside a td cell that's breaking the layout. I guess I'll have to use a link instead.

Image

Re: Layout issue

Posted: Fri Aug 18, 2017 10:27 pm
by Kesstryl
Got it working, whew!

Re: Layout issue

Posted: Sat Aug 19, 2017 2:30 pm
by hallsofvallhalla
Sweet! What was it?

Re: Layout issue

Posted: Sun Aug 20, 2017 3:05 pm
by Kesstryl
hallsofvallhalla wrote:Sweet! What was it?
I just made links, and here's the code I went with

Code: Select all

	$clans = doquery($link, "SELECT * FROM {{table}}", "clan");
	while($list = mysqli_fetch_array($clans)) {
		$id = $list["id"];
		$name = $list['name'];
		$message = $list['message'];
		
		$page .="<tr class=\"nimekiri\"><td>$name</td><td>$members</td><td>$message</td><td><a href=\"index.php?do=clanjoin:".$list["id"]."\">Join</a><td></tr>";
		}	
	}
	
if($do != ""){
$do=protect($do);
if(!is_numeric($do)){die();}	
doquery($link, "UPDATE {{table}} SET clan='$do', clanjoin='1' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
$page .= "You have submitted your application to the clan.  You may go back to the <a href=\"index.php?do=clanjoin\">Clans page</a>";
}

Re: Layout issue

Posted: Mon Aug 21, 2017 8:43 pm
by hallsofvallhalla
Looks much cleaner as well.