Confused

Ok i have 4 items in the database that match the status = 0 but it only displays the first item. Am i missing something? This is the part of the code that is in question.

[php]


<?php

$query = “SELECT * FROM {$dbprefix}elite WHERE status = ‘0’ ORDER BY id ASC”;
$result = mysql_query($query)
or die(mysql_error());
while($row = mysql_fetch_array($result))
{
extract($row);

if($logged_in == “1”) {
echo "
$name
$gamemode
$date
$time


";
}
}
?>

[/php]

You should use the following syntax to get the data from a database:

$query = “SELECT * FROM {$dbprefix}elite WHERE status = ‘0’ ORDER BY id ASC”;

$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result)){
$logged_in=$row[‘logged_in’];
if($logged_in == “1”) {
echo “$name
$gamemode
$date
$time

”;
}
}

in $row[‘logged_in’] replace ‘logged_in’ for whatever field name it corresponds to in the database.

That’s it!!

cheers,
Ray
www.Raynbowsoft.com

actually logged_in is defined already… here is the whole file

[php]<?php
$randomimage = getRandomImage();

$membername = $_SESSION[‘membername’];
$memberpass = $_SESSION[‘memberpass’];

$query = “INSERT INTO {$dbprefix}ips (ipaddress) VALUES (’$ip’)”;
$result = mysql_query($query);

/// News tickers info
$newstickercolor = textFilter(getWSInfo(“newstickercolor”));
$newsticker = textFilter(getWSInfo(“newsticker”));
$newssticker = textFilter(getWSInfo(“newssticker”));

?>


<?php echo $newsticker; ?>
*** ALERTS: <?php echo $newssticker; ?> ***

<?php if($randomimage != "") { echo ""; } ?>

<?php if($logged_in == "1") { include("include/whosonline.php"); } ?>
<?php $securitylevel = getWSInfo("securitylevel"); $recruiting = getWSInfo("recruiting");

if($recruiting == 0) { $recruiting = “ropen.jpg”; } else { $recruiting = “rclosed.jpg”; }

?>

Armored Core Gaming is officially recognized by the Central Outpost as a genuine gaming organization.

Elite Ops: Upcoming
<?php

$query = “SELECT * FROM {$dbprefix}elite WHERE status = ‘0’”;
$result = mysql_query($query)
or die(mysql_error());
while($row = mysql_fetch_array($result))
{
extract($row);

if($logged_in == “1”) {
echo "
$name
$gamemode
$date
$time


";
}
}
?>

Clan Security Level: Clan Recruiting Status:




Website Statistics
<?php $hits = getWSInfo("hits"); $unique = countUniqueHits(); $mostmembers = getWSInfo("mostmembers"); $mostmembersdate = getWSInfo("mostmembersdate"); $newhits = $hits+1;

$query = “UPDATE {$dbprefix}wsinfo SET hits = ‘$newhits’ WHERE id = ‘1’”;
$result = mysql_query($query)
or die(mysql_error());

echo "



Most Members Online: $mostmembers on $mostmembersdate

Total Visitors: $newhits

Unique Visitors: $unique
"; ?>
Proud Sponsors of ACG!



Proud Member of the Central Outpost
The Central Outpost - The Headquarters for Gaming Clans


Site Designed and modified by:

Need help with your clan contact Nuker_Viper here.
[/php]

disregaurd last… $logged_in is defined in the header.php file and means it displays the following only if a member is logged in. the problem i am having is i cannot get it to dispaly all 4 entries that match the query. It only displays the first 1.

nvm i made it a single entry with a text…

I am going to leave this till i get an answer for this that works.

[php]while($row = mysql_fetch_array($result))[/php]

This won’t goto the next row. Instead, use mysql_fetch_row($result)

The only thing with fetch row, is that it returns it as an enumerated array. As such, instead of extract, you’d have to use $row[0], $row[1] etc.

so do it like a function… never thought about that… ty

something like this?

[php]<?php

function getEliteEvents() {
global $dbprefix;
$i = 0;

$query = “SELECT * FROM {$dbprefix}elite WHERE status = ‘0’ ORDER BY id ASC”;
$result = mysql_query($query)
or die(mysql_error());
while($row = mysql_fetch_array($result))
{
extract($row);
$events[$i][0] = $id;
$events[$i][1] = $name;
$events[$i][2] = $gamemode;
$events[$i][3] = $date;
$events[$i][4] = $time;

$i++;
}

return $events;
}

?>[/php]

having trouble with the display still…

Function –
[php]<?php

function getEliteEvents() {
global $dbprefix;
$i = 0;

$query = “SELECT * FROM {$dbprefix}elite WHERE status = ‘0’ ORDER BY id ASC”;
$result = mysql_query($query)
or die(mysql_error());
while($row = mysql_fetch_array($result))
{
extract($row);
$events[$i][0] = $id;
$events[$i][1] = $name;
$events[$i][2] = $gamemode;
$events[$i][3] = $date;
$events[$i][4] = $time;
$events[$i][5] = $result;
$events[$i][6] = $players;

$i++;
}

return $events;
}

?>[/php]

file –
[php]<?php
echo "

"; $events = getEliteEvents(); foreach($events as $elite) { echo " ";

}

echo “

Elite Ops: Upcoming
$elite[1]
$elite[2]
$elite[3]
$elite[4]

”;

?>php]

Results:

Elite Ops: Upcoming
Head Hunters
Hc KC
June 29th
2-5pm EST

just the first one again… :-[

Sponsor our Newsletter | Privacy Policy | Terms of Service