Show table data that will be active briefly with disabled attribute and also data that is already active?

Asked

Viewed 45 times

-1

I have this code below and working, it publishes the data only when it indicates 1 in the 'Ready' field of the table, and if it is the number 0 the data is not shown. But I wanted that when the table data that is marked with 0, and that is words represented by butons, in this case indicating therefore that they are not published, were published with the disabled attribute, to show the user the themes or words that will soon be active. Someone has an idea about this programming?

<?php 
include 'conn.php';

$letter = $_GET["letter"];

$sql = "SELECT id,palavra from dicionario_basico  where Pronta != 0 AND palavra LIKE '".$letter."%' ORDER BY palavra";

$result = $conn->query($sql);


$sql2 = "SELECT DISTINCT(SUBSTR(`palavra`, 1, 1)) As abc from dicionario_basico   where pronta != 0 ORDER BY abc";

$result2 = $conn->query($sql2);

?>

2 answers

1

You can pick up all the items

$sql = "SELECT id,palavra from dicionario_basico where palavra LIKE '".$letter."%' ORDER BY palavra";

$sql2 = "SELECT DISTINCT(SUBSTR(palavra, 1, 1)) As abc from dicionario_basico ORDER BY abc";

so in your html table you insert a css class if the result has 0 tips, like this:

<table>
    <?php foreach($results as $key=>$value): ?>
    <tr class="<?php echo ($value['pontas'] == 0 ? 'disabled' : '')?>">
        <td><?php echo $key; ?></td>
    </tr>
    <?php endforeach; ?>
</table>

then in css you can style all tr with the class disabled


tr.disabled {
   color: gray;
}
  • At the moment it’s like this and I still can’t associate or exchange for your code: <tbody> <! -- WORD LIST --> <tr> <th Scope="Row" id="" style="background-color:#fafafa;"><? php if ($result->num_rows > 0) { while($Row = $result->fetch_assoc()) { ?>

  • The solution is in <?php echo ($value['pontas'] == 0 ? 'disabled' : '')?>. my code is just an example.

0


Try it this way: You can pick up all the items ...

<?php 
include 'conn.php';

$letter = $_GET["letter"];

$sql = "SELECT id,palavra,pronta from dicionario_basico where palavra LIKE '".$letter."%' ORDER BY palavra";

$result = $conn->query($sql);


$sql2 = "SELECT DISTINCT(SUBSTR(`palavra`, 1, 1)) As abc from dicionario_basico where pronta != 0 ORDER BY abc";

$result2 = $conn->query($sql2);

?>

table in html insert a class if the result is 0 or 1 ready, type like this:

<th scope="row" id="" style="background-color:#fafafa;"><?php 
                  if ($result->num_rows > 0) {
                  while($row = $result->fetch_assoc()) {
                      if($row["pronta"] == 1){
                   ?>

then on the active word button css, or marked with 1, you can style like this ...

<button style="margin-top:-2px;font-weight:bold; font-size:14px; border:none;" type="button" class="btn btn-outline-primary"><? echo $row["palavra"]; ?></button></a><br/>
            <?
          }else{?>

and in the css of inactive and 0-marked words you can style the tr with the disabled class. These words are visible but without the active link so that users only know the words that will soon be active).

<button style="margin-left:-16px;margin-top:-2px;font-weight:bold; font-size:14px; border:none;-moz-outline-style:none;" type="button" aria-disabled="true" class="btn btn-outline-primary btn-lg disabled" ><? echo $row["palavra"]; ?></button><br/>
          <? }
      }
    }
?>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.