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: [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

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

By Jake - July 9, 2008

Hi Charles,

I took a look at your page, and your table tags are closing for each record, so the loop is set up correctly. I did notice though that you're using an "id" attribute for one of your table cells in the loop. The "id" attribute should be unique, but in this case it's being repeated for each record. You might want to try converting this to a class, since this could be confusing the browser and affecting the layout. Failing that, send me an email to jake@interactivetools.com with your FTP information for this server and I'll take a look at the file directly to see if I can resolve this problem for you. [:)]
-----------------------------------------------------------
Cheers,
Jake Marvin - Product Specialist
support@interactivetools.com

Hire me!
Save time by getting our experts to help with your project. Template changes, advanced features, full integration, whatever you need. Whether you need one hour or fifty, get it done fast with Priority Consulting.