Jump to content

[SOLVED] Array help


Attila

Recommended Posts

Let me show you what the problem is please go to this link http://thaczero.com/cloak.php you will notice that under Item Name the Bards Cloak and the Cape of the Rock have hyperlinks.  If you click on the link it brings up a picture of the item.  But if you notice next to the name is an item description field and that has dissapeared nothing is there.  If you look in the table the information exist but it is not being posted.

 

Here is the page you are viewing

<?
// start the session 
session_start();
ob_start();
include ('includes/allfunctions.php');
header("Cache-control: private"); //IE 6 Fix 
?>
<title>DDO Items</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="CSS/style.css" rel="stylesheet" type="text/css">
<body class="body">
<div align="center">
<? 
include ('includes/header.php');
include ('includes/tindex.php');
//Connect to the database all fields are good so far


$sql = 'SELECT * FROM `ddoitems` WHERE `ItemType` LIKE \'%Cloak%\' ORDER BY ItemName ASC';
database_connect();
tables($sql);
?>	
</table>
</td>
  </tr>
    <td align="center" valign="bottom"><? include ('includes/footer.php')?>
   </td>
</table>
</div>
</html>

 

here is the code for tables($sql)

 


function tables($sql)
{
database_connect();
$result = mysql_query($sql) or die(mysql_error());
$count = "A";
while($row = mysql_fetch_array($result)) {
	if ($count == "A" )
		{  //start if
		if ($row['hyperlink'] == NULL) 
			{ //start if has an end
				echo '<tr class="cellbg1"><div align="center">';
        			                          echo '<td>'.$row['ItemName'].'</td>';
				echo '<td> <div align="left">'.$row['ItemDescription'].'</div></td>';
				echo '<td>'.$row['Type'].'</td>';
				echo '<td>'.$row['QuestName'].'</td>';
				echo '<td>'.$row['lvl'].'</td>';
				echo '<td>'.$row['Notes'].'</td>';
        			                          echo '</div> </tr>';
				$count = "B";
			} else {  //end if start else else has end
						echo '<tr class="cellbg1"><div align="center">';
			        	                         echo '<td> <a href="'.$row['hyperlink'].'"target="_blank">'.$row['ItemName'].'</a></td>';
           					                         echo '<td> <div align="left"'.$row['ItemDescription'].'</div></td>';
						echo '<td>'.$row['Type'].'</td>';
						echo '<td>'.$row['QuestName'].'</td>';
						echo '<td>'.$row['lvl'].'</td>';
						echo '<td>'.$row['Notes'].'</td>';
			        	                          echo '</div> </tr>';
						$count = "B";
					} // end else
		} else {
			if ($row['hyperlink'] == NULL)

			{ 
				echo '<tr class="cellbg2"><div align="center">';
        			                         echo '<td>'.$row['ItemName'].'</td>';
				echo '<td> <div align="left">'.$row['ItemDescription'].'</div></td>';
				echo '<td>'.$row['Type'].'</td>';
				echo '<td>'.$row['QuestName'].'</td>';
				echo '<td>'.$row['lvl'].'</td>';
				echo '<td>'.$row['Notes'].'</td>';
        			                          echo '</div></tr>';
				$count = "A";
			} else {
				echo '<tr class="cellbg2"><div align="center">';
			        	echo '<td> <a href="'.$row['hyperlink'].'"target="_blank">'.$row['ItemName'].'</a></td>';
           					echo '<td> <div align="left"'.$row['ItemDescription'].'</div></td>';
				echo '<td>'.$row['Type'].'</td>';
				echo '<td>'.$row['QuestName'].'</td>';
				echo '<td>'.$row['lvl'].'</td>';
				echo '<td>'.$row['Notes'].'</td>';
			        	echo '</div> </tr>';
				$count = "A";
			}
		}
	}

}


 

My database is set up in this order:

ID

Item Name

Item Description

Type

Quest

Name

LVL

Notes

Hyperlink

 

I am not sure as to why the link picture is working but why the name link is not working.

 

Any suggestions....And yes I am a self taught PHP and Mysql so I am sure there could have been better ways to do this code. :(

 

Thanks,

Link to comment
Share on other sites

inside your mysql_fetch_array brackets, do the following:

 

echo "<pre>";
print_r($row);
echo "</pre>";

 

...and let us know if the values are being successfully pulled out of the database.  Your code looks syntactically correct as far as i can see.  Unfortunately I can only pull up the item list page.  The hyperlink'd pages are blocked from the network I'm currently on.

Link to comment
Share on other sites

I did what you asked thanks nice thought, and the items are being pulled out of the database.  So what next?

 

Here is the example of what it is printing for the Bards Cloak:

Array

(

    [0] => 346

    [iD] => 346

    [1] => Bards Cloak

    [itemName] => Bards Cloak

    [2] => Cloak

    [itemType] => Cloak

    [3] => Greater Command (CL:9, 2/Day), Charisma +6, Perform +15

    [itemDescription] => Greater Command (CL:9, 2/Day), Charisma +6, Perform +15

    [4] => Raid

    [Type] => Raid

    [5] => A Vision of Destruction

    [QuestName] => A Vision of Destruction

    [6] => 18

    [lvl] => 18

    [7] => Raid Warded Chest

    [Notes] => Raid Warded Chest

    [8] => http://i153.photobucket.com/albums/s220/jgould2005/DDO/Items/Cloaks/BardsCloak.jpg

    [hyperlink] => http://i153.photobucket.com/albums/s220/jgould2005/DDO/Items/Cloaks/BardsCloak.jpg

)

 

 

Link to comment
Share on other sites

It is doing it in 2 spots so I will post both of them:

 

echo '<tr class="cellbg1"><div align="center">';
echo '<td> <a href="'.$row['hyperlink'].'"target="_blank">'.$row['ItemName'].'</a></td>';
           	echo '<td> <div align="left"'.$row['ItemDescription'].'</div></td>';
echo '<td>'.$row['Type'].'</td>';
echo '<td>'.$row['QuestName'].'</td>';
echo '<td>'.$row['lvl'].'</td>';
echo '<td>'.$row['Notes'].'</td>';
echo '</div> </tr>';
$count = "B";

 

echo '<tr class="cellbg2"><div align="center">';
        	echo '<td> <a href="'.$row['hyperlink'].'"target="_blank">'.$row['ItemName'].'</a></td>';
echo '<td> <div align="left"'.$row['ItemDescription'].'</div></td>';
echo '<td>'.$row['Type'].'</td>';
echo '<td>'.$row['QuestName'].'</td>';
echo '<td>'.$row['lvl'].'</td>';
echo '<td>'.$row['Notes'].'</td>';
       	echo '</div> </tr>';
$count = "A";

 

THe only diference between the two above is that the colum is formated diferently because of its class.

This one works without the hyperlink

 


echo '<tr class="cellbg2"><div align="center">';
echo '<td>'.$row['ItemName'].'</td>';
echo '<td> <div align="left">'.$row['ItemDescription'].'</div></td>';
echo '<td>'.$row['Type'].'</td>';
echo '<td>'.$row['QuestName'].'</td>';
echo '<td>'.$row['lvl'].'</td>';
echo '<td>'.$row['Notes'].'</td>';
echo '</div></tr>';
$count = "A";

Link to comment
Share on other sites

My bad I am sorry here you go:

 

<title>DDO Items</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="CSS/style.css" rel="stylesheet" type="text/css">
<body class="body">
<div align="center">
<link href="../CSS/style.css" rel="stylesheet" type="text/css" />
<table>
  <tr class="headertable"> 
    <td class="style2">
  <p align="center" class="style2"><strong><font size="+3"><em>DDO Items</em></font></strong></p>
  <div align="center"><font color="#FFFFFF" size="2">
  | <a href="index.php">Thaco Home</a> 
  | <a href="items.php">DDO Items Home</a> 
      | <a href="weapons.php">Weapons</a> 
  | <a href="armor.php">Armor</a> 
      | <a href="shields.php">Shields</a> 
  | <a href="bracers.php">Bracers</a> 
      | <a href="gloves.php">Gloves</a> 
  | <a href="boots.php">Boots</a>
  | <a href="helm.php">Helm</a> 
  | <a href="trinkets.php">Trinkets</a> 
      | <a href="rings.php">Rings</a> 
  | <a href="belts.php">Belts</a> 
      | <a href="cloak.php">Cloak</a> 
  | <a href="goggles.php">Goggles</a> 
  | <a href="necklace.php">Necklace</a> 
  | <a href="arrows.php">Arrows / Bolts</a> 
  | <a href="robe.php">Robe</a> 
  | <a href="misc.php">Misc</a> 
  | <a href="search.php">Search</a> 
  | <a href="../forum/index.php">Forums</a> |
      </font> </div>
</td>
  </tr>  </tr>
<link href="../CSS/style.css" rel="stylesheet" type="text/css" />

  <tr> 
     <td align="left" valign="top">
<table>
  <tr class="style2">
    <td><div align="center">Item Name </div></td>
    <td><div align="center">Item Description </div></td>
    <td><div align="center">Type</div></td>
    <td><div align="center">Quest Name</div></td>
    <td><div align="center">LVL</div></td>
    <td><div align="left">Notes</div></td>
  </tr><tr class="cellbg1"><div align="center"><td>Accomplice</td><td> <div align="left">Move Silently +10, Hide +10, Charisma -1</div></td><td>Reward</td><td>(Threnal Series)</td><td></td><td>End Reward Choice</td></div> </tr><tr class="cellbg2"><div align="center"><td>Banner Cloak</td><td> <div align="left">Charisma +6</div></td><td>Quest</td><td>Litany of the Dead</td><td>15</td><td>Vol's Chest</td></div></tr><tr class="cellbg1"><div align="center"><td> <a href="http://i153.photobucket.com/albums/s220/jgould2005/DDO/Items/Cloaks/BardsCloak.jpg"target="_blank">Bards Cloak</a></td><td> <div align="left"Greater Command (CL:9, 2/Day), Charisma +6, Perform +15</div></td><td>Raid</td><td>A Vision of Destruction</td><td>18</td><td>Raid Warded Chest</td></div> </tr><tr class="cellbg2"><div align="center"><td>Black Wolfskin Cloak</td><td> <div align="left">Lesser Cold Resistance, Resistance +2</div></td><td>Reward</td><td>Assualt on Splinterskull (TR Series)</td><td></td><td>End Reward Choice</td></div></tr><tr class="cellbg1"><div align="center"><td>Bronkarzs Cloak</td><td> <div align="left">Will Save +1</div></td><td>Quest</td><td>The Kobolds' New Ringleader</td><td>2</td><td>Bronkarz's Chest</td></div> </tr><tr class="cellbg2"><div align="center"><td> <a href="http://thaczero.com/Pictures/itempics/CapeoftheRoc.jpg"target="_blank">Cape of the Roc</a></td><td> <div align="left"Roc's Strength (CL:8, 3/rest), Feather Falling</div></td><td>Quest</td><td>Chains of Flame</td><td>12</td><td>End Chest</td></div> </tr><tr class="cellbg1"><div align="center"><td>Cloak of Curses</td><td> <div align="left">Chaotic Curse, Enchantment Focus</div></td><td>Quest</td><td>The Cursed Crypt</td><td>11</td><td>?</td></div> </tr><tr class="cellbg2"><div align="center"><td>Cloak of Ice</td><td> <div align="left">Exclusive, Fireshield (cold version) (CL:7, 3/rest)</div></td><td>Quest</td><td>Ghosts of Perdition</td><td>14</td><td></td></div></tr><tr class="cellbg1"><div align="center"><td>Cloak of Invisibility</td><td> <div align="left">Invisibility (CL:3, 1/rest), Invisibility</div></td><td>Quest</td><td>Tempest Spine</td><td>10</td><td>A'tchkar's Chest</td></div> </tr><tr class="cellbg2"><div align="center"><td>Cloak of Protection</td><td> <div align="left">Spell Resistance (17), Protection +3</div></td><td>Quest</td><td>Shadow Crypt</td><td>9</td><td>Big Chest Room</td></div></tr><tr class="cellbg1"><div align="center"><td>Cloak of Shadows</td><td> <div align="left">Hdie +7, Move Silently +7, Protection +2</div></td><td>Quest</td><td>The Church and the Cult</td><td>9</td><td>End Chest</td></div> </tr><tr class="cellbg2"><div align="center"><td>Cloak of Silence</td><td> <div align="left">+5 Move Silently</div></td><td>Quest</td><td>Redwillow's Ruins</td><td>6</td><td>Drow Chest</td></div></tr><tr class="cellbg1"><div align="center"><td>Cloak of the Asylum</td><td> <div align="left">Will Save +2, Wisdom +1</div></td><td>Reward</td><td>Archbishops Daughet (Catacomb Series)</td><td></td><td>End Reward Choice</td></div> </tr><tr class="cellbg2"><div align="center"><td>Cloak of the Silver Concord</td><td> <div align="left">Charisma +2, Haggle +10, Diplomacy +10, Persuasion</div></td><td>Raid</td><td>Plane of Night</td><td>10</td><td>Raid Warded Chest</td></div></tr><tr class="cellbg1"><div align="center"><td>Cloak of the Zephyr</td><td> <div align="left">Blurry, Invisibilty 1/day</div></td><td>Raid</td><td>Zawabi's Revenge</td><td>12</td><td>Raid Warded Chest</td></div> </tr><tr class="cellbg2"><div align="center"><td>Cloak of Troll's Resistance</td><td> <div align="left">Lesser Cold Resistance, Lesser Lightning Resistance, Lesser Sonic Resistance</div></td><td>Quest</td><td>Redwillow's Ruins</td><td>6</td><td>?</td></div></tr><tr class="cellbg1"><div align="center"><td>Dream Cloak</td><td> <div align="left">Deep Slumber (CL:5, 3/rest), Enchantment Focus, Charisma +3</div></td><td>Quest</td><td>Twilight Forge</td><td>12</td><td>End Chest</td></div> </tr><tr class="cellbg2"><div align="center"><td>Furor's Hide</td><td> <div align="left">Lesser Axeblock</div></td><td>Quest</td><td>Garrison's Missing Pack</td><td>2</td><td>Furor's Chest</td></div></tr><tr class="cellbg1"><div align="center"><td>Ghost-Waking Cloak</td><td> <div align="left">Charisma +3, Resistance +3</div></td><td>Quest</td><td>The Crucible</td><td>14</td><td>?</td></div> </tr><tr class="cellbg2"><div align="center"><td>Hellfire Cloak</td><td> <div align="left">Lesser Fire Resistance, Lesser Acid Resistance, Lesser Sonic Resistance</div></td><td>Reward</td><td>Return to Deleras Tomb (Deleras Series)</td><td></td><td>End Reward Choice</td></div></tr><tr class="cellbg1"><div align="center"><td>Jungle Cloak</td><td> <div align="left">Regrowth (CL:1, 1/rest), Hide +10</div></td><td>Raid</td><td>The Titan Awakes</td><td>12</td><td>Raid Warded Chest</td></div> </tr><tr class="cellbg2"><div align="center"><td>Mantle of Stria</td><td> <div align="left">Axeblock</div></td><td>Quest</td><td>The Bloody Crypt</td><td>6</td><td>?</td></div></tr><tr class="cellbg1"><div align="center"><td>Mantle of the Dragonfriend</td><td> <div align="left">Charisma +5, Diplomacy +7</div></td><td>Quest</td><td>Gianthold Tor</td><td>14</td><td>?</td></div> </tr><tr class="cellbg2"><div align="center"><td>Moss Weave Cloak</td><td> <div align="left">Fortitude Save +2, Constitution +1</div></td><td>Reward</td><td>The Lost Seekers (WW Series)</td><td></td><td>End Reward Choice</td></div></tr><tr class="cellbg1"><div align="center"><td>Quilted Cape</td><td> <div align="left">Sonic Resistance, Move Silently +7, Resistance +2</div></td><td>Reward</td><td>Cult of the Six (CO6 Series)</td><td></td><td>End Reward Choice</td></div> </tr><tr class="cellbg2"><div align="center"><td>Scurvys Cloak</td><td> <div align="left">Lesser Fire Resistance</div></td><td>Quest</td><td>Irestone Inlet</td><td>4</td><td>Scurvy</td></div></tr><tr class="cellbg1"><div align="center"><td>Stormreaver's Napkin</td><td> <div align="left">Intelligence +6, Spell Focus Mastery +1</div></td><td>Raid</td><td>The Reaver's Fate</td><td>14</td><td>Raid Warded Chest</td></div> </tr><tr class="cellbg2"><div align="center"><td>Widow Weave Cloak</td><td> <div align="left">Acid Resistance, Lesser Spearblock, Web Immunity, Proof against Poison</div></td><td>Reward</td><td>The Spawn of Whisperdoom Collectables</td><td></td><td>End Reward Choice (Goblet)</td></div></tr><tr class="cellbg1"><div align="center"><td>Witchdoctors Mantle</td><td> <div align="left">Will Save +2, Power II</div></td><td>Reward</td><td>Seal of Shan-to-Kor</td><td></td><td>End Reward Choice</td></div> </tr><tr class="cellbg2"><div align="center"><td>Wretched Twilight</td><td> <div align="left">Ghostly, Superior Nullification VI, Stealth Strike</div></td><td>Raid</td><td>Ascension Chamber</td><td>15</td><td>Raid Warded Chest</td></div></tr>	
</table>
</td>
  </tr>
    <td align="center" valign="bottom"><link href="../CSS/style.css" rel="stylesheet" type="text/css" />
          <div align="left" class="style2"><font size="-1">Web Design by <a href="mailto:tarman@thaczero.com">Tarman Thaco</a> <br>
          Copyright © 2008-2009 DDO Items. All 
  Rights Reserved. </font><br>
</div>   </td>
</table>
</div>
</html>

Link to comment
Share on other sites

Uhh have a look at this:

 

	echo '<td> <div align="left"'.$row['ItemDescription'].'</div></td>';

 

Your not closing the opening div, so that tag would look like this:

 <div align="left"Greater Command (CL:9, 2/Day), Charisma +6, Perform +15</div>

 

Add in the > in that echo statement.

 

	echo '<td> <div align="left">'.$row['ItemDescription'].'</div></td>';

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.