Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
107 views
in Technique[技术] by (71.8m points)

php - Dynamic table not displaying on mobile device.. similar static data does?

I'm running into an issue where a dynamically created table in PHP, echo'd in the body of the HTML tag, is not displaying at all on my mobile device. The same information is displayed correctly on my PC.

If I take the output from PHP in text form and paste it into the HTML portion, then the table displays correctly, in both my mobile and desktop environments.

For example, the following will display correctly in both my mobile and desktop environments.

<table class="table table-striped table-sm text-nowrap">
  <thead>
    <tr>
      <th scope="col">Class</th>
      <th scope="col">Heading</th>
      <th scope="col">Heading</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">Default</th>
      <td>Cell</td>
      <td>Cell</td>
    </tr>

    <tr class="table-primary">
      <th scope="row">Primary</th>
      <td>Cell</td>
      <td>Cell</td>
    </tr>
    <tr class="table-secondary">
      <th scope="row">Secondary</th>
      <td>Cell</td>
      <td>Cell</td>
    </tr>
  </tbody>
</table>

As an example, the following will only display on my desktop correctly.

<?php

$_tble = '    <tr>
      <th scope="row">Default</th>
      <td>Cell</td>
      <td>Cell</td>
    </tr>

    <tr class="table-primary">
      <th scope="row">Primary</th>
      <td>Cell</td>
      <td>Cell</td>
    </tr>
    <tr class="table-secondary">
      <th scope="row">Secondary</th>
      <td>Cell</td>
      <td>Cell</td>
    </tr>';

?>


<table class="table table-striped table-sm text-nowrap">
  <thead>
    <tr>
      <th scope="col">Class</th>
      <th scope="col">Heading</th>
      <th scope="col">Heading</th>
    </tr>
  </thead>
  <tbody>
        <?php echo $_tble; ?>
  </tbody>
</table>

Does anyone have any suggestion or ideas as to why this might be happening??

Using - Bootstrap 4.3, php 7.2.33

question from:https://stackoverflow.com/questions/65859280/dynamic-table-not-displaying-on-mobile-device-similar-static-data-does

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This originally appeared to be an issue with the creation of the table in PHP but ultimately turned out to be an issue with the $sql used to build the table.

The $sql was handled differently in different browsers. Inadvertently a TABLE name in the query was coded in upper case which correctly ran in IE/Firefox but not in IOS/Chrome.

For example:

Select * FROM TABLE1;

should have been written

Select * FROM table1;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...