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
https://forums.phpfreaks.com/topic/152766-solved-array-problem/
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
https://forums.phpfreaks.com/topic/152766-solved-array-problem/#findComment-802191
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
https://forums.phpfreaks.com/topic/152766-solved-array-problem/#findComment-802258
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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