What php code is needed in a table cell

7 posts by 3 authors in: Forums > CMS Builder
Last Post: July 9, 2008   (RSS)

By chassa2556 - July 7, 2008

Hi

I want to adjust the code that is generated to work in a two cell table but it keeps on coming up with error messages. Are there essential beginning and end tags that are needed in each cell. I can't seem to get the formula right?

Re: [chassa2556] What php code is needed in a table cell

By Dave - July 7, 2008

Hi Charles,

Can you post the code (small snippet is fine) and the error?

Thanks!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] What php code is needed in a table cell

By chassa2556 - July 7, 2008

I've emailed you Dave. I wonder if you could let me know as a general rule what 'end if' type statements need to go in a cell. If one column is text and the other pics.

Re: [chassa2556] What php code is needed in a table cell

By Dave - July 7, 2008

Hi Charles,

There's no special php code required for tablecells. PHP doesn't "know" anything about HTML, it can just repeat blocks of text and display information from your database.

What you need to do is figure out exactly what html you want repeated. Once you get that part figure out it will be much easier.

Try doing this is plain html first. Create a file with an html comment around a content row. You should be able to copy and paste that row a few times to repeat it without any problems.

Next, create a block of code with comments around it for your images. You should be able to copy and paste that block multiple times without breaking the design.

Once you get that far try adding the foreach loop first around the article row - get that working - then around the images in the row.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] What php code is needed in a table cell

By chassa2556 - July 9, 2008

Hi Dave

This is my code I'm using for a three row (one with just a rule in it) and two column table. But the problem is that it draws the first table indented to the rest - so is it not looping correctly?? I'm still not quite clear as to what should be included where for the 'foreach' loop in each cell and how it needs to close.

http://www.straloch.com/cms/clients-list.php<table width="500" height="276" border="0" align="left" id="contentTable">
<!--'-->
<tr>
<td width="430" height="172" valign="top"><?php foreach ($clientsRecords as $clientsRecord): ?>
<h1><?php echo $clientsRecord['client_name'] ?></h1>
<p><?php echo $clientsRecord['content'] ?><br/>
Record Number: <?php echo $clientsRecord['num'] ?><br/>
Home page (url): <?php echo $clientsRecord['home_page_url'] ?><br/>
_link : <a href="<?php echo $clientsRecord['_link'] ?>"><?php echo $clientsRecord['_link'] ?></a><br/>
</p></td>
<td width="231" align="right" valign="top"><?php foreach ($clientsRecord['screenshot'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>
<?php endif ?>
<?php endforeach ?> </td>
</tr>

<tr>
<td height="48" colspan="2" valign="top" id="contentTableRule2"><hr /></td>
</tr>
<tr>
<td height="48" colspan="2" valign="top"><p>
<?php if (!$clientsRecords): ?>
No records were found!<br/>
<?php endif ?>
<?php endforeach; ?>
</p></td>
</tr>
</table

Re: [chassa2556] What php code is needed in a table cell

By Dave - July 9, 2008

Hi Charles,

The first step is to figure out what HTML code you want repeated. Can you indicate what html you want repeated for each record and for each image? You can use the tags [red]content[/red] and [blue]content[/blue] around forum content to change the color.
Dave Edis - Senior Developer
interactivetools.com