Jump to content

[SOLVED] Array Problem


DEVILofDARKNESS

Recommended Posts

Hi, If I come on the page with this code, I only see one region_name from the table :-s

What have I done wrong?

 

<?php
session_start();
require_once 'login-check.php';
	/*DATABASE SETTINGS */
$nationid = $_SESSION['nationid'];
$username = $_SESSION['username'];
$query = "SELECT user_id FROM users WHERE user_name = '$username'";
$result = mysql_query($query);
list($userID) = mysql_fetch_row($result);
if($nationid == $id) {
$navigation = "gov.php?nation_id=" . $nationid;
}else{
$navigation = "loggedin.php?nation_id=" . $nationid;
}
$query = "SELECT * FROM regions WHERE region_ruler_id <> '$userID'";
$result = mysql_query($query);
while($regions = mysql_fetch_array($result)) {
?>
<html>
<head>
	<title>
		EUROPIA!
	</title>
	<meta name="author" content="Kruptein">
<link rel="shortcut icon" href="/images/favicon.ico">
</head>
<body>
	<table border="1" width="100%" height="100%">
		<tr>
			<td colspan = "3" height="15%">
				<b><u><center>EUROPIA!</center></u></b>
			</td>
		</tr>
		<tr>
			<td width="10%">
				<iframe src="/navigation/<?php echo $navigation; ?>" frameborder="0" width="100%" scrolling="no" height="100%"></iframe>
			</td>
			<td height="80%" width="90%">
			<center>
				Attack A Region!<p>
				Regions you can conquer:<br> <?php echo $regions['region_name'] . "<br>"; ?>
				</center>
			</td>
		</tr>
		<tr>
			<td colspan = "3" height="5%">
				<center>Made by Kruptein</center>
			</td>
		</tr>
	</table>
</body>
</html>
<?php
}
?>

Link to comment
Share on other sites

I have fixed $id,

and $userID is defined on line 9, you probably looked over it,

but it didn't change anything, it only showed me an other value from the table, but I want to show them all.

 

<?php
session_start();
require_once 'login-check.php';
/*DATABASE SETTINGS */
$nationid = $_SESSION['nationid'];
$username = $_SESSION['username'];
$query = "SELECT user_id FROM users WHERE user_name = '$username'";
$result = mysql_query($query);
list($userID) = mysql_fetch_row($result);
if($nationid == $userID) {
$navigation = "gov.php?nation_id=" . $nationid;
}else{
$navigation = "loggedin.php?nation_id=" . $nationid;
}
$query = "SELECT * FROM regions WHERE region_ruler_id <> '$userID'";
$result = mysql_query($query);
while($regions = mysql_fetch_array($result)) {
?>
<html>
<head>
	<title>
		EUROPIA!
	</title>
	<meta name="author" content="Kruptein">
<link rel="shortcut icon" href="/images/favicon.ico">
</head>
<body>
	<table border="1" width="100%" height="100%">
		<tr>
			<td colspan = "3" height="15%">
				<b><u><center>EUROPIA!</center></u></b>
			</td>
		</tr>
		<tr>
			<td width="10%">
				<iframe src="/navigation/<?php echo $navigation; ?>" frameborder="0" width="100%" scrolling="no" height="100%"></iframe>
			</td>
			<td height="80%" width="90%">
			<center>
				Attack A Region!<p>
				Regions you can conquer:<br> <?php echo $regions['region_name'] . "<br>"; ?>
				</center>
			</td>
		</tr>
		<tr>
			<td colspan = "3" height="5%">
				<center>Made by Kruptein</center>
			</td>
		</tr>
	</table>
</body>
</html>
<?php
}
?>

Link to comment
Share on other sites

Your creating an entire html page for each record. In order for your page to be rendered properly by a browser it needs to adhere to html standards, those standards dictate that you can only have one <html> element in your page.

Link to comment
Share on other sites

Alright?

HOw Can I solvit?

 

?>
<html>
<head>
	<title>
		EUROPIA!
	</title>
	<meta name="author" content="Kruptein">
<link rel="shortcut icon" href="/images/favicon.ico">
</head>
<body>
	<table border="1" width="100%" height="100%">
<?php
while($regions = mysql_fetch_array($result)) {
?>
		<tr>
			<td colspan = "3" height="15%">
				<b><u><center>EUROPIA!</center></u></b>
			</td>
		</tr>
		<tr>
			<td width="10%">
				<iframe src="/navigation/<?php echo $navigation; ?>" frameborder="0" width="100%" scrolling="no" height="100%"></iframe>
			</td>
			<td height="80%" width="90%">
			<center>
				Attack A Region!<p>
				Regions you can conquer:<br> <?php echo $regions['region_name'] . "<br>"; ?>
				</center>
			</td>
		</tr>
		<tr>
			<td colspan = "3" height="5%">
				<center>Made by Kruptein</center>
			</td>
		</tr>
<?php
}
?>
	</table>
</body>
</html>

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.