Jump to content


Photo

Displaying a Repeat Region


  • Please log in to reply
5 replies to this topic

#1 pikemsu28

pikemsu28
  • Members
  • PipPipPip
  • Advanced Member
  • 164 posts

Posted 19 September 2006 - 06:56 PM

I'm not sure if this is the right forum but............

Is it possible to display a repeat region that only displays one occurance of a value from one table column and displays all records from other columns?

I have a table that is populated with user submitted information (name, signup date, signup time, etc)

I want a table that will display the data in the "signup" table but only to display one occurance of the person's name and multiple date and time values.

<table width="100%" cellpadding="2" cellspacing="1" border="1" id="CBT Report">
  <tr id="Labels">
    <th width="10%" align="left" valign="bottom" class="style2">Name</th>
    <th width="10%" align="left" valign="bottom" class="style2">Date</th>
    <th width="8%" align="left" valign="bottom" class="style2">Time</th>
    <th width="12%" align="left" valign="bottom" class="style2">Email</th>
  </tr>
  <?php do { ?>
  <tr class="style2" id="ReportInfo">
      <td width="10%" height="23" valign="top"><?php echo ucwords($row_report['first_name'])." ".ucwords($row_report['last_name']); ?></td> //only want one occurance of this from database
      <td valign="top" width="10%"><?php echo $row_report['date']; ?></td>
      <td valign="top" width="8%"><?php echo $row_report['time']; ?></td>
      <td valign="top" width="12%"><?php echo $row_report['email']; ?></td>
    </tr><?php } while ($row_report = mysql_fetch_assoc($report)); ?>
</table>

Any idea on how to accomplish this? 

#2 sasa

sasa
  • Staff Alumni
  • Advanced Member
  • 2,804 posts
  • LocationHrvatska

Posted 19 September 2006 - 07:58 PM

try
<table width="100%" cellpadding="2" cellspacing="1" border="1" id="CBT Report">
  <tr id="Labels">
    <th width="10%" align="left" valign="bottom" class="style2">Name</th>
    <th width="10%" align="left" valign="bottom" class="style2">Date</th>
    <th width="8%" align="left" valign="bottom" class="style2">Time</th>
    <th width="12%" align="left" valign="bottom" class="style2">Email</th>
  </tr>
  <?php
$tmp_name='';
 do { ?>
  <tr class="style2" id="ReportInfo">
<?php
$name = ucwords($row_report['first_name'])." ".ucwords($row_report['last_name']);
if($name != $tmp:name){
?>
 <td width="10%" height="23" valign="top"><?php echo ucwords($row_report['first_name'])." ".ucwords($row_report['last_name']); ?></td> //only want one occurance of this from database
<?php
} else echo '<td width="10%" height="23" valign="top">&nbsp;</td>';
$tmp_name = $name;
?>
      <td valign="top" width="10%"><?php echo $row_report['date']; ?></td>
      <td valign="top" width="8%"><?php echo $row_report['time']; ?></td>
      <td valign="top" width="12%"><?php echo $row_report['email']; ?></td>
    </tr><?php } while ($row_report = mysql_fetch_assoc($report)); ?>
</table>


#3 pikemsu28

pikemsu28
  • Members
  • PipPipPip
  • Advanced Member
  • 164 posts

Posted 20 September 2006 - 05:15 PM

Thanks for replying sasa,

I tried this but i'm receiving an error:

Parse error: parse error, unexpected ':' in C:\NursingServer\test.php on line 102

if($name != $tmp:name){ //this is line 102 in my code


#4 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 20 September 2006 - 05:20 PM

It's a typo, change that line to...

if($name != $tmp_name){


Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#5 pikemsu28

pikemsu28
  • Members
  • PipPipPip
  • Advanced Member
  • 164 posts

Posted 20 September 2006 - 06:25 PM

IT WORKED!!!!

Thanks Huggie and sasa

#6 sasa

sasa
  • Staff Alumni
  • Advanced Member
  • 2,804 posts
  • LocationHrvatska

Posted 20 September 2006 - 07:33 PM

It's a typo, change that line to...

if($name != $tmp_name){


Regards
Huggie

thanks HuggieBear




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users