At the moment I have a text area where people can insert their own sql scripts for people to see however it currently displays quite bland.
I was wondering if there was a way in which using Jquery/Javascript/PHP that when people load a note from the database, it then does a check through a list of words. For example "SELECT", "FROM", "WHERE", "INNER", "JOIN" and if they match it sets the colour of them to a defined colour?
This would need to happen when the note is displayed on the screen as the text is coming from a database. So maybe there is some way to check the words as they are pulled through from the database.
These notes are being pulled through as follows:
if (isset($_POST['noteid']))
{
$showNoteInfo = "SELECT Note, NoteName FROM Notes WHERE NoteID = " . $_POST['noteid'];
$stmt = sqlsrv_query($conn, $showNoteInfo);
}
if (isset($_POST['noteid']))
{
if (empty($_POST['noteid']))
{
$notes = 'No Data';
}
if (sqlsrv_has_rows($stmt))
{
$data = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC);
echo "<div class='custom-font title-container'>
<div class='expand-button-container fa fa-expand' onclick='expandWindow()'></div>
<div id='title-container1'><div class='edit-note fa fa-pencil' onclick='editGeneralNote()'> </div>" . "<div data-toggle='modal' data-target='#editNoteNameModal' class='display-inline'>" . $data['NoteName'] . "</div>" . " <div class='save-note fa fa-thumbs-up' onclick='saveGeneralNote(); submitNoteText();'></div></div>
</div>";
echo "<textarea spellcheck='false' readonly id='ta1'>" . $data['Note'] . "</textarea>";
}
else
{
echo "No data found";
}
}
So how can I colour certain words pulled through from a database as they are displayed on screen?
If anyone could help I would appreciate it.