I am struggling with the problem after an AJAX request. I am querying data from a database. This alone works great, and I process the data and add it to the table in the PHP file. This table consists of a header followed by data. Then this table is transferred to the main page where it is displayed. My problem is that I am trying to format the buttons that I create in PHP for formatting. Here is php with data request
if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql = "SELECT LoginName FROM table"; $res = mysqli_query($conn, $sql); if (mysqli_num_rows($res) > 0) { echo "<center>"; echo "<table border='1'>"; echo "<tr>"; echo "<td>User</td>"; echo "<td colspan=2 align=center>Available Functions</td>"; echo "</tr>"; while($row = mysqli_fetch_assoc($res)) { echo "<tr>"; echo "<td>" . $row['User'] . "</td>"; echo "<td><button type='button' class='smallbutton'>Delete User</button></td>"; echo "<td><button type='button' class='smallbutton'>Change Password</button></td>"; echo "</tr>"; } echo "</table>"; echo "</center>"; } else { echo ""; } mysqli_close($conn);
As you can see, I assigned the class to the buttons. I thought it was easy to use as a formatting tag for CSS. My css file is as follows:
.smallbutton { font-size:16px; padding: 10px 10px; border: none; background-color: #008CBA; box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2), 0 3px 10px 0 rgba(0,0,0,0.19); color: white; }
Each time the code that is on the page refresh is executed, a table is created, but the buttons look like those ugly standard buttons, and CSS is not applied. I was able to incorporate the style into a PHP file, which then worked, but thatβs not the way I want to structure my page. PHP is really just a data provider, and I want to use CSS in a central place for layouts.
I already use the same CSS with just a different class name for the other buttons, and they work fine no matter where they are on the page. Only these in the table that I create do not want to work.
The table is embedded in a div that has the identifier "DbInfo" and is populated through innerHTLM.
Just in case, here is also my AJAX team:
$(document).ready(function(){ $.ajax({ method: "POST", url: "UserData.php", success: function(data){ $("#DbInfo").innerHTML = data; } }); });
Does anyone help?
Thanks...