Jump to content

Need some display help


fewchurpro

Recommended Posts

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

[code]<?
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>";


?>[/code]



And the file to show the item

show_weapon.php

[code]<?


$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>
[/code]

Its probably very messy, again im pretty new and have been trying hard to get it right.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

[!--quoteo(post=350456:date=Feb 28 2006, 05:32 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Feb 28 2006, 05:32 PM) [snapback]350456[/snapback][/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. :(
Link to comment
Share on other sites

[!--quoteo(post=350517:date=Feb 28 2006, 09:31 PM:name=wickning1)--][div class=\'quotetop\']QUOTE(wickning1 @ Feb 28 2006, 09:31 PM) [snapback]350517[/snapback][/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
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.