Jump to content

Pulling a List of data and it stops on first record


overlordofevil

Recommended Posts

Hello All,

 

So I am a bit confused about something and cant figure out how to fix it..

 

I am working with a db of user data. What I am trying to do is pull up the info and collecting data from other tables as well.  The issue I am having is when I get the info based on the group id all the basic info will come up and the entire list of user data I want to get comes up no problem. When I try to add in the other code to get the info from other tables that i want it just stops at the first record.

 

So when I do the first step of gathering the data i want and displaying it on the screen,  here is the code.

 

<html>
<body>
<?php
include ("misc.inc");
include ("functions.inc");
include ("charfun.inc");
$query = "SELECT * FROM characters INNER JOIN id ON characters.id = id.id where id.chid='$chid'";
echo "<table>";
$result = mysql_query($query) or die (mysql_error());
while ($row = mysql_fetch_array($result))
{
echo "<tr><td>"; 
extract($row);
$cname = "$firstname $lastname";
$uid = $id;
$classid=$clas;
$armor = getarmor($cid, $classid);
$gobbies = getgoblinpoints($uid);
$racename = getracename($race);
$classname = getclassname($clas);
$pname= getplayersname($uid); 
$chname = getchaptername($uid);
$notes=getnotes($cid);
$email = getemail($uid);
echo "<table width=100% border='1'>
<tr><td align ='center'>

<table><tr><td><big><big><big><b>NERO $chname Character Sheet</b></big></big></big></td></tr></table>

</td></tr>
<tr><td align ='center'>

<table><tr>
<TD ALIGN='right'><small><b>Player's Name: </b></td>
<TD ALIGN='left'><small>$pname</td>
<TD ALIGN='right'><small><b>Member's ID: </b></td>
<TD ALIGN='left'><small>$uid</td>
<TD ALIGN='right'><small><b>E-Mail Address: </b></td>
<TD ALIGN='left'><small>$email</td>
<TD ALIGN='right'><small><b>Goblin Points: </b></td>
<TD ALIGN='left'><small>$gobbies</td>
<TD ALIGN='right'><small><b></b></td>
<TD ALIGN='left'><small></td>
</tr></table>

</td></tr>
<tr><td align ='center'>

<table><tr>
<TD ALIGN='right'><small><b>Character's Name: </b></small></td><TD ALIGN='left'><small><b>$cname</b></small></td>
<TD ALIGN='right'><small><b></b></td>
<TD ALIGN='left'><small></td>
<TD ALIGN='right'><small><b></b></td>
<TD ALIGN='left'><small></td>
</tr><tr>
<TD ALIGN='right'><small><b>Race: </td><TD ALIGN='left'><small>$racename, $subrace</td>
<TD ALIGN='right'><small><b>Build: </td><TD ALIGN='left'><small>$build</td>
<TD ALIGN='right'><b><small>Body: </td><TD ALIGN='left'><small>$body</td>
</tr><tr>
<TD ALIGN='right'><b><small>Class: </td><TD ALIGN='left'><small>$classname</td>
<TD ALIGN='right'><b><small>Free Build: </td><TD ALIGN='left'><small>$freebuild</td>
<TD ALIGN='right'><b><small>XP: </td><TD ALIGN='left'><small>$xp</td>
</tr><tr>
<TD ALIGN='right'><small><b>Level: </td>
<TD ALIGN='left'><small>$level</td>
<TD ALIGN='right'><b><small>Max Armor: </td>
<TD ALIGN='left'><small>$armor</td>
<TD ALIGN='right'><b><small>Deaths: </td>
<TD ALIGN='left'><small>$deaths</td>
<td></td>
</tr></table>";
//Place holder for other code. 
echo" </td></tr>
</table>
</td></tr>";
}
echo "</table>";
?>
</body>
</html>

 

So with the above code it does the loop and pulls all the info as needed.  Now If I add the following in to the code it just stops on the first record.

 

<?php
// code goes where the place holder line is at.
<tr><td align ='center'>

<table><tr>
<td align='center'>
<table width=100% align='center'><tr><td align = 'center'><big><b>Fight/Weapon Skills</b></big></td></tr></table>
</td>
</tr><tr>
<td>
<table width=100% align='center'><tr><td align = 'center'>";
echo "<table><tr><td align = 'center'><small><b>Weapons and Armor</b></small></td></tr></table>";
$query = "SELECT * FROM skill1 where cid = '$cid' and type = '3' ORDER BY skillID";
$result = mysql_query($query) or die (" Line 1 Query failed due to: ".mysql_error());
echo "<table>";
while ($row = mysql_fetch_array($result))
{
extract($row);
echo "<tr>
<td align = 'center'><small>$skillName</small></td>
</tr>";
}
echo"</table>";
echo"</td></tr></table>
</td>
</tr></table>
</td></tr>

 

I have more code but the loop stops at anyone them so i just included this one to see if someone could explain why it would happen and what i am doing wrong with the scripts to pull the info. 

 

I know the layout might look off but this is not complete code I am just cutting and pasting what works and what happens when I add in the new code.

 

Any suggestions would be appreciated.

 

Thanks

Bill

Link to comment
Share on other sites

In short.. you have a loop in a loop.. One is breaking the other. Since you already have a cycle running in a loop why not match the second query to pull row specific data out from the other table based on the variable its using to pull the data already. It will do that on a row to row basis with each cycle of the loop.

 

To break down what I am saying.. Run each loop independantly in a seperate file, notice there outputs. What your doing with your code currently it trying is tell the first one to do what its going to display running it alone, then while thats going on tell it to do the samething the second one does alone within it.

 

Fix: your going to have to restyle your second query to work with the results of the first one. Pull the data on a row to row basis. Then display it the way you want based on that.

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.