Jump to content

Table with Row in multiple column


Tato123

Recommended Posts

Hi Guys,

i have a problem

<?php
if(!$allawardtpes)
{
echo 'Non sono disponibili Spille!';
return;
}
foreach($allawardtpes as $type)
{
?>
<h3><?php echo $type->typ_name;?></h3>
<p>
<?php
$allissuedawards = vAwardsData::GetAllIssuedAward($pilotid, $type->typ_id);
if(!$allissuedawards)
{
echo 'Nessuna Spilla Assegnata';
$allissuedawards = array();
}
foreach($allissuedawards as $award)
{
?>
<?php if(!empty($award->awd_image))
{
?>
<br />
<table>
<th><img src="<?php echo $award->awd_image;?>" /><th>
<th><?php echo $award->awd_name;?></th>
</table>
<?php
}
else
{
?>
Immagine Spilla non disponibile
<?php
}
?>
</p>
<?php
}
?>
<?php
}
?>

With this code, I create a table where each row corresponds to a given award

example:

A award

B award

C award

D award

E award

F award

I would like to create the table in this way:

Aaward Baward Caward

Daward Eaward Faward

Can anyone help me?

Link to comment
Share on other sites

Hi, thanks for help

I try with this code:

<?php
if(!$allawardtpes)
{
echo 'Non sono disponibili Spille!';
return;
}
foreach($allawardtpes as $type)
{
?>
<h3><?php echo $type->typ_name;?></h3>
 <?php
$allissuedawards = vAwardsData::GetAllIssuedAward($pilotid, $type->typ_id);
if(!$allissuedawards)
{
 echo 'Nessuna Spilla Assegnata';
 $allissuedawards = array();
}
foreach($allissuedawards as $award)
{
?>
 <?php if(!empty($award->awd_image))
{
?>
<br />
<table>
<div id="awards" style="float:left;text-align:left;"><img src="<?php echo $award->awd_image;?>" /></div>
</table>
 <?php
}
else
{
?>
 Immagine Spilla non disponibile
 <?php
}
?>
<?php
}
?>
<?php
}
?>

But the result is not good

error1.jpeg

Do yuo have any suggestion?

Thanks

Link to comment
Share on other sites

  • Moderators

Can you check if this works?

<?php
if(!$allawardtpes)
{
echo 'No category available';
return;
}
foreach($allawardtpes as $type)
{
?>
<h3><?php echo $type->typ_name;?></h3>
 <?php
$allissuedawards = vAwardsData::GetAllIssuedAward($pilotid, $type->typ_id);
if(!$allissuedawards)
{
 echo 'No issued awards';
 $allissuedawards = array();
}
foreach($allissuedawards as $award)
{
?>
 <?php if(!empty($award->awd_image))
{
?>
<br />
<p align="center"><img src="<?php echo $award->awd_image;?>" /></p>
 <?php
}
else
{echo 'No Image available';}
}
?>
<?php
}
?>

Link to comment
Share on other sites

  • Moderators

BTW, George :P

You may use this if you want to place them on the same line:

<?php
if(!$allawardtpes)
{
echo 'No category available';
return;
}
foreach($allawardtpes as $type)
{
?>
<h3><?php echo $type->typ_name;?></h3>
 <?php
$allissuedawards = vAwardsData::GetAllIssuedAward($pilotid, $type->typ_id);
if(!$allissuedawards)
{
 echo 'No issued awards';
 $allissuedawards = array();
}
foreach($allissuedawards as $award)
{
?>
 <?php if(!empty($award->awd_image))
{
?>
<p align="center"><img src="<?php echo $award->awd_image;?>" /></p>
 <?php
}
else
{echo 'No Image available';}
}
?>
<?php
}
?>

Link to comment
Share on other sites

  • Members

Voila

echo "<table>";
 echo "<tr>" ;
 $i = 0;

 foreach ($allawards as $award) {
	 if ($i % 3 === 0) {
		 echo '</tr><tr>';
	 }
	 echo "<td><img src=".$award->image." alt=".$award->descrip." /> </td>";
	 $i++;
 }
 echo "</tr>" ;
 echo "</table> ";

Try this it is fixed for 3 rows but if you want more or less change the number 3 to your choise at

if ($i % 3 === 0)

Link to comment
Share on other sites

thanks Vangelis, but don't work.

Where i put your code?

My original code is:

<?php
if(!$allawardtpes)
{
echo 'Non sono disponibili Spille!';
return;
}
foreach($allawardtpes as $type)
{
?>
<h3><?php echo $type->typ_name;?></h3>
<p>
 <?php
$allissuedawards = vAwardsData::GetAllIssuedAward($pilotid, $type->typ_id);
if(!$allissuedawards)
{
 echo 'Nessuna Spilla Assegnata';
 $allissuedawards = array();
}
foreach($allissuedawards as $award)
{
?>
 <?php if(!empty($award->awd_image))
{
?>
 <br />
<table>
<th><img src="<?php echo $award->awd_image;?>" /><th>
<th><?php echo $award->awd_name;?></th>
</table>
 <?php
}
else
{
?>
 Immagine Spilla non disponibile
 <?php
}
?>
</p>
<?php
}
?>
<?php
}
?>

Link to comment
Share on other sites

  • Members

Copy and paste this over your code and see if it works

My code didnt worked for you because i didnt saw that you are not using $allawards but $allissuedawards = vAwardsData::GetAllIssuedAward($pilotid, $type->typ_id);

If the code below is not working please tell me in witch page or template do you want to show it and if you are using a custom awards module because the build in module for awards does not require you to do $allissuedawards = vAwardsData::GetAllIssuedAward($pilotid, $type->typ_id); in the template in order to show the pilot awards

<?php
$allissuedawards = vAwardsData::GetAllIssuedAward($pilotid, $type->typ_id);
if(!$allissuedawards)
echo 'Nessuna Spilla Assegnata';
else{
echo "<table>";
 echo "<tr>" ;
 $i = 0;

 foreach ($allissuedawards as $award)
{
	 if ($i % 3 === 0) {
		 echo '</tr><tr>';
	 }
	 echo "<td><img src=".$award->image." alt=".$award->descrip." /> </td>";
	 $i++;
 }
 echo "</tr>" ;
 echo "</table> ";
}

Link to comment
Share on other sites

  • Members

Copy and paste this over your's in /templates/profile_issued_awards.tpl

<?php
if(!$allawardtpes)
{
echo 'There is no awards available!';
return;
}
foreach($allawardtpes as $type)
{
?>
<h3><?php echo $type->typ_name;?></h3>
<?php
$allissuedawards = vAwardsData::GetAllIssuedAward($pilotid, $type->typ_id);
if(!$allissuedawards)
{
 echo 'Nessuna Spilla Assegnata';
 $allissuedawards = array();
}
echo "<table>";
	 echo "<tr>" ;
	 $i = 0;
foreach($allissuedawards as $award)
{
			 if ($i % 3 === 0) {
					 echo '</tr><tr>';
			 }
			 echo "<td><img src=".$award->awd_image." alt=".$award->descrip." />
			 <br /><strong>Award Name:</strong>".$award->awd_name."<br /></td>";
			 $i++;
	 }
	 echo "</tr>" ;
	 echo "</table> ";
 }



?>

This is tested with the version that i downloaded 2day from Kyle's github

Link to comment
Share on other sites

  • 2 years later...

<?php
if(!$allawardtpes)
{
echo 'There is no awards available!';
return;
}
foreach($allawardtpes as $type)
{
?>
<h3><?php echo $type->typ_name;?></h3>
<?php
$allissuedawards = vAwardsData::GetAllIssuedAward($pilotid, $type->typ_id);
if(!$allissuedawards)
{
	 echo 'Nessuna Spilla Assegnata';
	 $allissuedawards = array();
}
echo "<table>";
			 echo "<tr>" ;
			 $i = 0;
foreach($allissuedawards as $award)
{
							 if ($i % 3 === 0) {
											 echo '</tr><tr>';
							 }
							 echo "<td><img src=".$award->awd_image." alt=".$award->descrip." />
							 <br /><strong>Award Name:</strong>".$award->awd_name."<br /></td>";
							 $i++;
			 }
			 echo "</tr>" ;
			 echo "</table> ";
	 }

?>

how do i take this tables line off? http://i.imgur.com/KG2IrU7.png

Link to comment
Share on other sites

  • 2 weeks later...

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.

Loading...
×
×
  • Create New...