Jump to content

Need help with displaying this Array() correctly..


CraftHell

Recommended Posts

Hi I appreciate everyone who helped me with my other problem trying to call my Array() I had issues with.

 

Heres what that looks like

http://crafted.horizon-host.com/ff/

 

Code from the above

<html>
<head>
<title>FINAL FANTASY XIV - Item Database</title>
<style type="text/css">
a:link {text-decoration: none; color: #FFFFFF}
a:visited {text-decoration: none; color: #FFFFFF}
a:hover {text-decoration: none; color: #FFFFFF}
a:active {text-decoration: none; color: #FFFFFF}
p.title {
font-size: medium;
font-family: Verdana;
color: #FFFFFF;
}
p.items {
font-size: small;
font-family: Verdana;
color: #FFFFFF;
}
</style>
<script src="http://static.yg.com/js/exsyndication.js" type="text/javascript">
</script>
<script type="text/javascript">
    YG.UserSettings.Syndication =
    {
        removeClasses: ['extern'],
        defaultClass: 'yg-iconsmall yg-name',
        clearTitle: true
    }
</script>
</head>
<body background="../images/testbg.jpg" marginwidth=60 marginheight=60>
<table align="center" id="Table_01" width=520 height=393 border=0 cellpadding=0 cellspacing=0>
<tr>
	<td width=520 height=14 colspan=5 background="../images/test_01.gif"></td>
</tr>
<tr>
	<td width=20 height=23 background="../images/test_02.gif"></td>
	<td colspan=3 background="../images/test_03.gif" align="center" valign="middle">
<p class='title'>FINAL FANTASY XIV - Item Database</p>
	</td>
	<td width=14 height=23 background="../images/test_04.gif"></td>
</tr>
<tr>
	<td width=520 height=7 colspan=5 background="../images/test_05.gif"></td>
</tr>
<tr>
	<td background="../images/test_06.gif"></td>
	<td colspan=3 background="../images/test_07.gif" align="center" valign="top">
<p class='items'>
<?php
function grabdata($site){
$page_contents = file_get_contents($site);
$pattern = '/\/item\/([a-z,-]+[^gil])\?id\=([0-9,]+)/';
preg_match_all($pattern, $page_contents, $matches);
$arrRetList = array();
if(!empty($matches)){
	foreach($matches as $item) {
	foreach($item as $pos => $row){
		$arrRetList[$pos][] = $row;	
	}
	}
	foreach($arrRetList as $row){
                	echo "<p class='items'><a href='http://ffxiv.yg.com" . $row[0] . "'>Unknown Item</a> - " . $row[1] . " - " . $row[2] . "<BR>";
	}
}
}
grabdata("http://ffxiv.yg.com/items?l=50:50;trd=0;cl=30");
?>
</p>
	</td>
	<td background="../images/test_08.gif"></td>
</tr>
<tr>
	<td colspan=2 width=23 height=17 background="../images/test_09.gif"></td>
	<td background="../images/test_10.gif"></td>
	<td colspan=2 width=17 height=17 background="../images/test_11.gif"></td>
</tr>
<tr>
	<td>
		<img src="../images/spacer.gif" width=20 height=1></td>
	<td>
		<img src="../images/spacer.gif" width=3 height=1></td>
	<td>
		<img src="../images/spacer.gif" width=480 height=1></td>
	<td>
		<img src="../images/spacer.gif" width=3 height=1></td>
	<td>
		<img src="../images/spacer.gif" width=14 height=1></td>
</tr>
</table>
</body>
</html>

 

Heres the code im trying to run, has some added stuff to the above <?php ?> code but its not viewing at all, just shows a white page.. and would like to get some advice on what im doing wrong

<?php
function grabdata($site){
$page_contents = file_get_contents($site);
$pattern = '/\/item\/([a-z,-]+[^gil])\?id\=([0-9,]+)/';
preg_match_all($pattern, $page_contents, $matches);
$arrRetList = array();
if(!empty($matches)){
	foreach($matches as $item) {
	foreach($item as $pos => $row){
		$arrRetList[$pos][] = $row;	
	}
	}
	foreach($arrRetList as $row){
                	echo $row[1] . " - " . $row[2] . "<BR>";
		echo "<table align='center' border='0' cellpadding='0' cellspacing='0' width='80%'><td align='left'><p class='items'>Item</td><td align='center'><p class='items'>NPC Price</td><tr><td align='left'><p class='items'><a href='http://ffxiv.yg.com" . $row[0] . "'>Unknown Item</a></td></td><td align='center'><p class='items'>";
		$page_contents2 = file_get_contents("http://ffxiv.yg.com" . $row[0] . "");
		$matches2 = array();
		preg_match_all('/<td class=\"lefttd\">Normal<\/td><td align=\"right\">([0-9,]+)<\/td><\/tr>/', $page_contents2, $matches2);
		if ($matches2[1][0] == ""){
			echo "0g - ";
		} else {
			print_r($matches2[1][0] . "g - ");
		}
		preg_match_all('/<td class=\"lefttd\">\+1<\/td><td align=\"right\">([0-9,]+)<\/td><\/tr>/', $page_contents2, $matches2);
		if ($matches2[1][0] == ""){
			echo "0g - ";
		} else {
			print_r($matches2[1][0] . "g - ");
		}
		preg_match_all('/<td class=\"lefttd\">\+2<\/td><td align=\"right\">([0-9,]+)<\/td><\/tr>/', $page_contents2, $matches2);
		if ($matches2[1][0] == ""){
			echo "0g - ";
		} else {
			print_r($matches2[1][0] . "g - ");
		}
		preg_match_all('/<td class=\"lefttd\">\+3<\/td><td align=\"right\">([0-9,]+)<\/td><\/tr>/', $page_contents2, $matches2);
		if ($matches2[1][0] == ""){
			echo "0g";
		} else {
			print_r($matches2[1][0] . "g");
		}
			echo "</td></tr>";
		}
		echo "</table><BR><BR><BR>";
	}
}
grabdata("http://ffxiv.yg.com/items?l=50:50;trd=0;cl=30");
?>

 

To give you a idea of what im looking for, it already grabs each item and list it  from grabdata(""); function, i wanna take that further by it grabs the item, and then uses that data to grab the item sell price (normal, +1, +2, +3 quality) for each display it out, something like..

ITEMNAME1   132g - 145g - 165g - 198g
ITEMNAME2   50g - 0g - 0g - 0g
ITEMNAME3   63g - 78g - 90g - 110g
etc etc

 

from the first $page_contents from $site

$row[0] will output: item url variables

$row[1] will output: item name

$row[2] will output: item #

 

from the second $page_contents from "http://ffxiv.yg.com" . $row[0] . ""

$matches2[1][0] will be numerical output of the prices for each preg_match_all

 

These scripts work separately just need them to work together :D

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.