Jump to content


Photo

Need some display help


  • Please log in to reply
5 replies to this topic

#1 fewchurpro

fewchurpro
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 28 February 2006 - 10:58 PM

Sorry Im pretty noobish and have been beating myself pretty hard on my issue, including going thru books and all the php/mysql pages. So here is what Im tryin to accomplish.


I run a gaming site, and have been putting weapons, armor, etc into a database. What im trying to accomplish is when they go to the page for like say weapons they get a menu of the items. I have started one and got the menu part to work at [a href=\"http://osa.guild-studio.com/index2.php\" target=\"_blank\"]http://osa.guild-studio.com/index2.php[/a]

I tried using some help from one of the books I purchased on php a while back on how to make the individual item show up when you click on the name but thus far, ive been completely unsuccessful. I'll copy and paste the files I've been butchering up here and hopefully someone can help me out. (UN and PW intentionally not there for this)

NOTE: I am in no way needing people to log-in, edit, modify, change, add, delete or anything, this is strictly for VIEWING only.

Files:

index.php

<?
mysql_connect("localhost", "*******", "*****");
mysql_select_db("guild_xmltestingdb") or die( "Unable to select database");
$query="SELECT * FROM ds_weaponshib";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

echo "<b><center>Database Output</center></b><br><br>";

?>
<table border="1" cellspacing="2" cellpadding="2">
<tr>
<th><font face="Arial, Helvetica, sans-serif">Weapon</font></th>
</tr>

<?
$i=0;
while ($i < $num) {
$wep_id=mysql_result($result,$i,"wep_id");
$Itemname=mysql_result($result,$i,"Itemname");
?>

<tr>
<td><font face="Arial, Helvetica, sans-serif"><a href="show_weapon.php?wep_id=$wep_id\"><? echo "$Itemname"; ?></a></font></td>
</tr>
<?
++$i;
}
echo "</table>";


?>



And the file to show the item

show_weapon.php

<?


$db_name = "guild_xmltestingdb";
$table_name = "ds_weaponshib";

$connection = @mysql_connect("localhost", "****", "****") or die("Couldn't connect.");

$db = @mysql_select_db($db_name, $connection) or die("Couldn't select database.");

$chk_id = "SELECT id FROM $table_name WHERE wep_id  = \"$wep_id\"";
$chk_id_res = @mysql_query($chk_id,$connection) or die("Couldn't execute query.");
$chk_id_num = mysql_num_rows($chk_id_res);

{

    $sql = "SELECT wep_id, Itemname, Quality, Level, DPS, Speed, Bonus, Dam_type, Location, Offhand, s1_effect, s1_amount, s2_effect, s2_amount, s3_effect, s3_amount, s4_effect, s4_amount, s5_effect, s5_amount, s6_effect, s6_amount
        FROM $table_name
        WHERE wep_id = \"$wep_id\"
        ";

    $result = @mysql_query($sql,$connection) or die("Couldn't execute query.");


    while ($row = mysql_fetch_array($result)) {
        $wep_id = $row['wep_id'];
        $Itemname = $row['Itemname'];
        $Quality = $row['Quality'];
        $Level = $row['Level'];
        $DPS = $row['DPS'];
        $Speed = $row['Speed'];
        $Bonus = $row['Bonus'];
        $Dam_type = $row['Dam_type'];
        $Location = $row['Location'];
        $Offhand = $row['Offhand'];
        $s1_effect = $row['s1_effect'];
        $s1_amount = $row['s1_amount'];
        $s2_effect = $row['s2_effect'];
        $s2_amount = $row['s2_amount'];
        $s3_effect = $row['s3_effect'];
        $s3_amount = $row['s3_amount'];
        $s4_effect = $row['s4_effect'];
        $s4_amount = $row['s4_amount'];
        $s5_effect = $row['s5_effect'];
        $s5_amount = $row['s5_amount'];
        $s6_effect = $row['s6_effect'];
        $s6_amount = $row['s6_amount'];

    }

}

?>


<HTML>
<HEAD>
<TITLE>My Weapon Management System: Read-Only Contact Details</TITLE>
</HEAD>
<BODY>

<h1>My Weapon Management System</h1>
<h2>DS Hibernia Weapon Details for <? echo "$Itemname"; ?></h2>

<P><strong>Weapon:</strong><br>
<? echo "$Itemname"; ?><br>
<?
   echo "<strong>Quality:</strong> $Quality <br>";
   echo "<strong>Level:</strong> $Level <br>";
   echo "<strong>DPS:</strong> $DPS <br>";
   echo "<strong>Speed:</strong> $Speed <br>";
   echo "<strong>Bonus:</strong> $Bonus <br>";
   echo "<strong>Type:</strong> $Dam_type <br>";
   echo "<strong>Hand:</strong> $Location <br>";
   echo "<strong>LH Usable:</strong> $Offhand <br>";
   echo "<strong>Slot 1:</strong> $s1_amount $s1_effect <br>";
   echo "<strong>Slot 2:</strong> $s2_amount $s2_effect <br>";
   echo "<strong>Slot 3:</strong> $s3_amount $s3_effect <br>";
   echo "<strong>Slot 4:</strong> $s4_amount $s4_effect <br>";
   echo "<strong>Slot 5:</strong> $s5_amount $s5_effect <br>";
   echo "<strong>Slot 6:</strong> $s6_amount $s6_effect <br>";
?>





</BODY>
</HTML>

Its probably very messy, again im pretty new and have been trying hard to get it right.

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 01 March 2006 - 01:32 AM

I don't really understand why you don't put the ouput in the while loop (which should be an if, btw, since you're searching by UID). That way, you can skip all those variable assignments and just do the output straight.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 fewchurpro

fewchurpro
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 01 March 2006 - 01:42 AM

[!--quoteo(post=350456:date=Feb 28 2006, 05:32 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Feb 28 2006, 05:32 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I don't really understand why you don't put the ouput in the while loop (which should be an if, btw, since you're searching by UID). That way, you can skip all those variable assignments and just do the output straight.
[/quote]


Mostly because Im new and dont really know any better. My poor eyes are burned out trying to sort thru this and looking up info to help me do this. Im pretty lost now. :(

#4 fewchurpro

fewchurpro
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 01 March 2006 - 02:37 AM

What can I do with what I have there? Or do I need to just scrap the whole project and start at ground zero?

#5 wickning1

wickning1
  • Members
  • PipPipPip
  • Advanced Member
  • 405 posts

Posted 01 March 2006 - 05:31 AM

<a href="show_weapon.php?wep_id=$wep_id\"><? echo "$Itemname"; ?></a>

You are in HTML mode when you call $wep_id. Do this instead:
<a href="show_weapon.php?wep_id=<? echo "$wep_id\"> $Itemname"; ?></a>

#6 fewchurpro

fewchurpro
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 01 March 2006 - 05:47 AM

[!--quoteo(post=350517:date=Feb 28 2006, 09:31 PM:name=wickning1)--][div class=\'quotetop\']QUOTE(wickning1 @ Feb 28 2006, 09:31 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
<a href="show_weapon.php?wep_id=$wep_id\"><? echo "$Itemname"; ?></a>

You are in HTML mode when you call $wep_id. Do this instead:
<a href="show_weapon.php?wep_id=<? echo "$wep_id\"> $Itemname"; ?></a>
[/quote]

That worked. Thank you so much for the help.

/bows




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users