I am trying to dynamically display helpful Notes on screen to users.
If you go to http://discovertheplanet.net/general_notes.php
The list on the left is how many rows there are in my Notes table.
There are three columns in my database, 'NoteID', 'NoteName' and 'Note'
Each 'NoteName' is pulled from the database and is given an ID using the 'NoteID' column in the database
The PHP/HTML:
<div class="main-container-notes">
<div id="left-box">
<?php
echo "<div style='width: 100%;'>";
while( $noteName = sqlsrv_fetch_array( $resultNotes, SQLSRV_FETCH_ASSOC))
{
echo "<div class='hvr-bounce-to-right1 hover-cursor output' data-noteid='{$noteName['NoteID']}' style='width: 100%; border-right: 5px solid #00AA88; height: 50px;'>" . $noteName['NoteName'] . "</div>";
}
echo "</div>";
?>
</div>
<div id="right-box">
<!-- Where the actual full note description will go -->
</div>
</div>
My current script: which is in my <script type="text/javascript" src="scripts/scripts.js"></script>
Looks like:
$(".output").click(function() {
var noteid = $(this).data("noteid");
$("#right-box").load("connectionDetails.php", { noteid: noteid });
});
EDIT
This is my connectionDetails.php:
<?php
$myServer = "replacement";
$connectionInfo = array('Database' => 'DiscoverThePlanet', 'UID' => 'replacement', 'PWD' => 'replacement');
//connection to the database
$conn = sqlsrv_connect($myServer, $connectionInfo)
or die("Couldn't connect to SQL Server on $myServer");
//Test connection to server
// if ($conn)
// {
// echo "connection successful"; # code...
// }
//Defining my queries
$getNotes = "SELECT NoteID, NoteName, Note FROM Notes";
$getTemplateNotes = "SELECT TemplateNoteID, TemplateNoteName, TemplateNote FROM TemplateNotes";
$getReplaceVariables = "SELECT ReplaceVariableID, ReplaceVariableName, ReplaceVariableNote FROM ReplaceVariables";
$resultNotes = sqlsrv_query( $conn, $getNotes );
$resultTemplate = sqlsrv_query($conn, $getTemplateNotes);
$resultVariables = sqlsrv_query($conn, $getReplaceVariables);
if( $resultNotes === false)
{
die( print_r( sqlsrv_errors(), true) );
}
if( $resultTemplate === false)
{
die( print_r( sqlsrv_errors(), true) );
}
if( $resultVariables === false)
{
die( print_r( sqlsrv_errors(), true) );
}
?>
Not sure if it affects anything but i also have this included like so
<?php include 'connectionDetails.php'; ?>
So am i on the right lines as I'm new to this, and how do I now use the ID's I have, to pull through the 'Note' column when I click on the appropriate Div?
Example: I click on 'Test note' which has a NoteID of 1 it then checks the 'Note' column for NoteID 1 and pulls through 'This is a test piece of helpful text shown in my right container on the same screen'
I hope I have explained this well enough, if you need any more info, please just ask.
Many thanks in advance!