C++, C#, Java, PHP, ect...
NZAAN
Posts: 13 Joined: Sun Sep 27, 2009 12:16 am
Post
by NZAAN » Sat Mar 20, 2010 7:24 pm
To start off, I watched the tutorial vids... made the game, and then started from scratch once I had a fair understanding of what was going on. Currently, my problem is that when I list your "gear"... if you have something attached to your weapon, the attachment carries through every item in the list. I have tried everything I can think of as a beginner, and to no avail.
Code: Select all
echo "<small>";
print "<center>";
print "<table border='0' width='70%' cellspacing='20'>";
print "<tr><td width='25%' valign='top'>";
print "</td>";
print "<td valign='top' width='75%'>";
$iteminfo="SELECT * from items where playerid='$playerid'";
$iteminfo2=mysql_query($iteminfo) or die("could not get item stats!");
print "<table border='1' bordercolor='#404040' bgcolor='#404040'>";
print "<tr><td><b>Name</b><font color='#404040'>________________</font></td><td><b>Increase</b><font color='#404040'>______</td><td><font color='#404040'><b>Attachment</b>___</td><td><b><font color='#404040'>Rare</b><font color='#404040'>______</td><td><b>Level</b><font color='#404040'>______</td></tr>";
while($iteminfo3=mysql_fetch_array($iteminfo2))
{
$getinfo="SELECT * from items where attachment='0'";
$getinfo2=mysql_query($getinfo) or die("could not get info..");
$getinfo3=mysql_fetch_array($getinfo2);
$weaponattachedto = $getinfo3['weaponid'];
$currentscan = $iteminfo3['id'];
if ($weaponattachedto = $currentscan)
{
$attachname = "None";
} *** IF I TAKE THIS OUT, THE PROBLEM HAPPENS ***
else *** IF I LEAVE IT IN, EVERYTHING HAS AN ***
{ *** ATTACHMENT OF "None" ***
$attachname = $attachinfo3['name'];
}
print "<tr><td>$iteminfo3[name]<font color='#404040'>__---</font><A href='remove.php?id=$iteminfo3[id]'>Remove</a></td><td>$iteminfo3[base]</td><td>$attachname</td><td>$iteminfo3[rare]</td><td>$iteminfo3[level]</td></td><td>";
$counter = 1;
}
print "</table>";
print "</td></tr></table>";
print "</center>";
echo "</small>";
jpoisson
Posts: 245 Joined: Sun Aug 02, 2009 5:12 pm
Post
by jpoisson » Sat Mar 20, 2010 10:59 pm
ok firstly in you if statemate you are not comparing the two values properly, but assigning a new value to
Code: Select all
if ($weaponattachedto = $currentscan)
it should be
Code: Select all
if ($weaponattachedto == $currentscan)
NZAAN
Posts: 13 Joined: Sun Sep 27, 2009 12:16 am
Post
by NZAAN » Sun Mar 21, 2010 12:15 am
I've updated the code, and now instead of both rows having an attachment of "None", they're using the attachment of the only weapon with an attachment.
What I want to do, is to make it display the name of the attachment, if there is one. So I should be seeing an attachment of $attachname for one row... and an attachment of None for the other.
I dont get it :S
Code: Select all
$iteminfo="SELECT * from items where playerid='$playerid'";
$iteminfo2=mysql_query($iteminfo) or die("could not get item stats!");
print "<table border='0' bordercolor='#404040' bgcolor='#ffffff'>";
print "<tr><td><b>Name</b><font color='#ffffff'>________________</font></td><td><b>Increase</b><font color='#ffffff'>______</td><td><font color='#ffffff'><b>Attachment</b>___</td><td><b><font color='#ffffff'>Rare</b><font color='#ffffff'>______</td><td><b>Level</b><font color='#ffffff'>______</td></tr>";
while($iteminfo3=mysql_fetch_array($iteminfo2))
{
$getinfo="SELECT * from items where attachment='0'";
$getinfo2=mysql_query($getinfo) or die("could not get info..");
$getinfo3=mysql_fetch_array($getinfo2);
$weaponattachedto = $getinfo3['weaponid'];
$currentscan = $iteminfo3['id'];
if ($weaponattachedto == $currentscan)
{
$attachname = "None";
}
print "<tr><td>$iteminfo3[name]<font color='#ffffff'>---</font><A href='remove.php?id=$iteminfo3[id]'>Remove</a></td><td>$iteminfo3[base]</td><td>$attachname</td><td>$iteminfo3[rare]</td><td>$iteminfo3[level]</td></td><td>";
$counter = 1;
}
Torniquet
Posts: 869 Joined: Sun Aug 02, 2009 6:18 am
Post
by Torniquet » Sun Mar 21, 2010 1:51 am
well for a start... that is VERY dodgy coding if i am seeing it right.
here is how i would do it...
Code: Select all
$sql = mysql_query("SELECT * FROM items WHERE playerid='$playerid'");
print "
<table>
<tr>
<td>
<b>Name</b><font color='#ffffff'>________________</font>
</td>
<td>
<b>Increase</b><font color='#ffffff'>______</font>
</td>
<td>
<b>Attachment</b><font color='#ffffff'>______</font>
</td>
<td>
<b>Rare</b><font color='#ffffff'>______</font>
</td>
<td>
<b>Level</b><font color='#ffffff'>______</font>
</td>
</td>
";
while($row = mysql_fetch_assoc($sql)){
if($row['attachment'] != 0){
$attachname = what ever is holding the name of the attachment goes here....;
} else {
$attachname = "None";
}
print"
<tr>
<td>
$iteminfo3[name]<font color='#ffffff'>---</font><A href='remove.php?id=$iteminfo3[id]'>Remove</a>
</td>
<td>
$iteminfo3[base]
</td>
<td>
$attachname
</td>
<td>
$iteminfo3[rare]
</td>
<td>
$iteminfo3[level]
</td>
";
}
</table>
or atleast something similar to that...
all depends how you have layed out your db tables.
New Site Coming Soon! Stay tuned