Jump to content

Round

Members
  • Content Count

    104
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Round

  • Rank
    Advanced Member

Profile Information

  • Gender
    Male
  • Location
    England
  1. The server is the version it has always been. I don't control the server. PHP was upgraded when it needed to be and has stayed the same since. Haven't had any issues still using mssql_ It seems sqlsrv is an easier transition for the code to be changed. I will be looking into upgrading requests and code change. Many thanks
  2. Ok so I have tried the example and as I'm using mssql and not mysql I have had to change it a bit. I now have: $sqlsn = "SELECT system_name FROM tbl_sub_systems WHERE section=\"21a\""; $rssn = mssql_query( $sqlsn, $conn) or die ("Cannot execute"); $data = array_chunk(mssql_fetch_array($rssn), 2); echo "<table border=\"1\">"; foreach ($data as $row) { echo "<tr>"; if (count($row)==2) { foreach ($row as $n) echo "<td>".$n['system_name']."</td>"; } else { echo "<td colspan=\"2\">".$row[0]['system_name']."</td>"; } echo "</tr>"; } echo "</table>"; But it only ever return a count of 2. So it only creates 1 row of the table which oddly displays the first letter of the first result in each column. So for instance I have 3 records: AB CD EF The desired result being +--------+--------+ | AB | CD | +--------+--------+ | EF | +-----------------+ but I am getting +--------+--------+ | A | A | +--------+--------+ If the records are: Z1 Y1 X1 I get: +--------+--------+ | Z | Z | +--------+--------+ For starters I don't even understand why it's only displaying the first letter?? I am truly lost. Many thanks
  3. Exactly barand. Thanks I will have a look and try your example
  4. Hello All, I really hope I explain this properly. What I am attempting to achieve and I'm failing miserably at is to create the table layout based on the number of rows returned from a query. Basically if 1 row is returned I want a table to be structured like: <table> <tr> <td></td> </tr> </table> If 2 rows are returned structure like: <table> <tr> <td></td> <td></td> </tr> </table> if 3 rows are returned structure like: <table> <tr> <td></td> <td></td> </tr> <tr> <td colspan="2"></td> </tr> </table> The number of rows returned by the query is infinite. The last row of the table needs to be spanned across the 2 columns if the row count returned is odd. If the row count returned is equal I want each row of the table to have two columns. I know that if only one row is returned I could use: <table> <tr> <td colspan="2"></td> </tr> </table> to satisfy any if's/loops. I am really struggling with the fact the number of record rows returned is unknown. Any help much appreciated
×
×
  • 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.