Jump to content

[SOLVED] Printing all information out from an array


adam291086

Recommended Posts

I am trying to print out all the information from an array using a for loop like so

 

for ($i=0; $i<=sizeof($pages); $i++)
{
?>
<tr>
  <td>
        <?php echo $pages['title']?>
  </td>
  <td>
       <?php echo $pages['description']?>
  </td>
</tr>
<?php
}

 

The array contains data from a query of the database. The number of rowd full of information can vary. At the moment it is supposed to print out one lot of information but instead it is printing out the same info 11 time.

 

I know its due to the sizeof function but how else can i loop through?

like

 

$pages = $add->get_page($domain,$account);

 

which looks like

 

Array ( [0] => 7 [id] => 7 [1] => www.adamplowman.co.uk [domain] => www.adamplowman.co.uk [2] => 123 [account_number] => 123 [3] => dfsdf [title] => dfsdf [4] => dsfsdfsd [description] => dsfsdfsd )

 

i just want every title and description printed out no matter how many there is

 

the fuction that pages use

function get_page($domain,$account)
{
	require_once('DbConnector.php');
	$loginConnector = new DbConnector();
	$getTemplate = $loginConnector->query("SELECT * FROM pages WHERE domain = '$domain' AND account_number='$account'");
	if ($loginConnector->getNumRows($getTemplate)<=0)	
	{
	$page = 'No Pages Found';
	}
	else
	{
	$page = $loginConnector->fetchArray($getTemplate);
	}
	return $page;

}

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.