Jump to content

Recommended Posts

Sorry for the silly question, I'm new to PHP  ;D ;D

 

Below is my report.php file:

<?php require_once('../Connections/Sencore.php'); ?>
<?php
mysql_select_db($database_Sencore, $Sencore);
$query_subVer = "SELECT * FROM `1067`";
$subVer = mysql_query($query_subVer, $Sencore) or die(mysql_error());
$row_subVer = mysql_fetch_assoc($subVer);
$totalRows_subVer = mysql_num_rows($subVer);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="../assets/css/style.css" rel="stylesheet" type="text/css" />
</head>

<body>

<table border="1">
  <tr>
    <td>IPAddress</td>
    <td>Notes</td>
    <td>alias</td>
    <td>unitversion</td>
    <td>decoderVersion</td>
    <td>tssid</td>
    <td>stationname</td>
  </tr>
  <?php do { ?>
    <tr>
      <td><?php echo $row_subVer['IPAddress']; ?></td>
      <td><?php echo $row_subVer['Notes']; ?></td>
      <td><?php echo $row_subVer['alias']; ?></td>
      <td><?php echo $row_subVer['unitversion']; ?></td>
      <td><?php echo $row_subVer['decoderVersion']; ?></td>
      <td><?php echo $row_subVer['tssid']; ?></td>
      <td><?php echo $row_subVer['stationname']; ?></td>
    </tr>
    <?php } while ($row_subVer = mysql_fetch_assoc($subVer)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($subVer);
?>

 

The output looks like this:

10.67.10.56 RX BU AUSTIN 6.3.0 6.3.0

10.67.10.35 RX 04 AUSTIN 6.3.0 6.3.0

10.67.10.34 RX 03 AUSTIN 6.3.0 6.3.0

10.67.10.33 RX 02 AUSTIN 6.3.0 6.3.0

10.67.10.32 RX 01 AUSTIN 6.3.0 6.3.0

10.67.12.56 RX BU DALLAS 6.3.0 6.3.0

10.67.12.35 RX 04 DALLAS 6.3.0 6.3.0

10.67.12.34 RX 03 DALLAS 6.3.0 6.3.0

10.67.12.33 RX 02 DALLAS 6.3.0 6.3.0

10.67.12.32 RX 01 DALLAS 6.3.0 6.3.0

 

What I'm trying to accomplish is that the output looks like this:

AUSTIN

10.67.10.56 RX BU 6.3.0 6.3.0

10.67.10.35 RX 04 6.3.0 6.3.0

10.67.10.34 RX 03 6.3.0 6.3.0

10.67.10.33 RX 02 6.3.0 6.3.0

10.67.10.32 RX 01 6.3.0 6.3.0

 

DALLAS

10.67.12.56 RX BU 6.3.0 6.3.0

10.67.12.35 RX 04 6.3.0 6.3.0

10.67.12.34 RX 03 6.3.0 6.3.0

10.67.12.33 RX 02 6.3.0 6.3.0

10.67.12.32 RX 01 6.3.0 6.3.0

 

I have no clue what to google to find something similar to this... ??? ??? ???

 

Any suggestions would greatly help, thanks in advance.

 

SeeFor

Link to comment
https://forums.phpfreaks.com/topic/146555-solved-php-grouping-output/
Share on other sites

try

<?php require_once('../Connections/Sencore.php'); ?>
<?php
mysql_select_db($database_Sencore, $Sencore);
$query_subVer = "SELECT * FROM `1067` ORDER BY decoderVersion";
$subVer = mysql_query($query_subVer, $Sencore) or die(mysql_error());
$row_subVer = mysql_fetch_assoc($subVer);
$totalRows_subVer = mysql_num_rows($subVer);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="../assets/css/style.css" rel="stylesheet" type="text/css" />
</head>

<body>

<table border="1">
  <tr>
    <td>IPAddress</td>
    <td>Notes</td>
    <td>alias</td>
    <td>unitversion</td>
    
    <td>tssid</td>
    <td>stationname</td>
  </tr>
  <?php 
  $curr_dec='';
  do { 
  if ($row_subVer['decoderVersion'] != $curr_dec){
  	echo "<tr><td colspan=\"6\">decoderVersion: $row_subVer[decoderVersion]</td></tr>";
  	$curr_dec = $row_subVer['decoderVersion'];
  }
  ?>
    <tr>
      <td><?php echo $row_subVer['IPAddress']; ?></td>
      <td><?php echo $row_subVer['Notes']; ?></td>
      <td><?php echo $row_subVer['alias']; ?></td>
      <td><?php echo $row_subVer['unitversion']; ?></td>
      
      <td><?php echo $row_subVer['tssid']; ?></td>
      <td><?php echo $row_subVer['stationname']; ?></td>
    </tr>
    <?php } while ($row_subVer = mysql_fetch_assoc($subVer)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($subVer);
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

×
×
  • 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.