Jump to content

Recommended Posts

Do you know why this:

<?PHP

//Include Files
include('Connect.php');
include('top.php');

//Define Variables
$GetID= $_GET['id'];
$ID= $_COOKIE['UserID'];
$UserName = $_COOKIE['UserName'];
$usercheck = addslashes($_POST['username']);
$result2 = mysql_query("SELECT * FROM users");
$rows2 = mysql_fetch_array($result2);
$result = mysql_query("SELECT * FROM pokemon_info WHERE user_id='$GetID' AND username='$usercheck'");
$rows= mysql_fetch_array($result);

//Encrypt Data
$GetID= mysql_real_escape_string($GetID);

//If User Is Not Logged In
if(!isset($ID))
{
echo "Sorry, you must be logged in to view this page.";
include('bottom.php');
exit;
}

//If User Does Not Exist
if(empty($rows))
{
//Display Message
echo "Sorry, the specified user does not exist.";

//Include Bottom File
include("bottom.php");

//Exit Page
exit;
}

//Find Slot
$result7= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$GetID' AND pokemon_slot='7'");
$rows7= mysql_fetch_array($result7);

//Define Pokémon Variables
$vp_pokemon_name7= $rows7['pokemon_name'];
$vp_pokemon_image7= $rows7['pokemon_image'];
$vp_pokemon_attack7= $rows7['pokemon_attack'];
$vp_pokemon_defence7= $rows7['pokemon_defence'];
$vp_pokemon_level7= $rows7['pokemon_level'];
$vp_pokemon_exp7= $rows7['pokemon_exp'];
$vp_pokemon_nexp7= $rows7['pokemon_nexp'];
$vp_pokemon_gender7= $rows7['pokemon_gender'];
$vp_attack17= $rows7['attack1'];
$vp_attack27= $rows7['attack2'];
$vp_attack37= $rows7['attack3'];
$vp_attack47= $rows7['attack4'];

while($rows = mysql_fetch_array($result));
{
//Display Information
echo "The box of user ID " . $rows['user_id'] . ":<br />";
echo "<table border='1' bgcolor='lightgrey'>";
echo "<br /><br />";
echo "<tr>";
echo "<td><center>" . $vp_pokemon_name7 .  "<br /><img border='0' src='" . $vp_pokemon_image7 .  "'></center></td></tr>";
echo "<tr><td>Attack: " . $vp_pokemon_attack7 . "</td></tr>";
echo "<tr><td>Defense: " . $vp_pokemon_defence7 . "</td></tr>";
echo "<tr><td>Level: " . $vp_pokemon_level7 . "</td></tr>";
echo "<tr><td>EXP: $vp_pokemon_exp7/" . $vp_pokemon_nexp7 . "</td></tr>";
echo "<tr><td>Gender: <br />" . $vp_pokemon_gender7 . "<br /></td></tr>";
echo "<tr><td><b>Moves:</b> <br /> " . $vp_attack17 . "<br />"
. $vp_attack27 . "<br />"
. $vp_attack37 . "<br />"
. $vp_attack47 . "<br /></td></tr></table>";
}
include('bottom.php'); 

?>

<br />Only displays the last box pokemon?

Link to comment
https://forums.phpfreaks.com/topic/83175-only-displays-last-box-pokemon/
Share on other sites

 

$rows= mysql_fetch_array($result);

while($rows = mysql_fetch_array($result));

 

those line fetches array.. so the first result will be given to first fetch and the second will be for your while loop meaning you will only get the second result up to the last result  in your while loop

 

 

i have answered this in JS forum hmm...

$result = mysql_query("SELECT * FROM pokemon_info WHERE user_id='$GetID' AND username='$usercheck'");
$rows= mysql_fetch_array($result);

$result7= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$GetID' AND pokemon_slot='7'");
$rows7= mysql_fetch_array($result7);

 

how many rows do you expect for those lines?

$result = mysql_query("SELECT * FROM pokemon_info WHERE user_id='$GetID' AND username='$usercheck'");
$rows= mysql_fetch_array($result);

$result7= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$GetID' AND pokemon_slot='7'");
$rows7= mysql_fetch_array($result7);

 

how many rows do you expect for those lines?

maybe you need to perform join in that two tables.

 

and try to put a comment on each query so we know what each query does ..

There will be unlimited users and pokemon.. So unlimited.

 

unlimited is not a number,

try to be realistic

999999999999999999999999999999999999999999999999999999999

then. Pokemon add up like crazy already.

 

And The result 7 is to mysql_fetch_array the box pokemon or the '7th' slot. The other one is to set their userid as the cookie makes it and same as the username.

 

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.