Let’s say I list a list of rows with a link like this:
content.php
/*DATABASE CONNECTION AND SQL STUFF*/
<div id='content'>
<?php
$sql = mysql_query ("SELECT id, somedata FROM myTable");
while ($row = mysql_fetch_assoc($sql)) {
echo "<a href='?p=moreData&id=" . $row['id'] . "'>" . $somedata . "</a><br />\n";
}
?>
</div>
moreData.php
<?php
$id = $_GET['id'];
/* SQL STUFF */
echo "More information about" . " ". $somedata. " " . "wich has an id of" . " " . $id;
How can I use the moreData.php to be loaded with $_GET information inside a new div called <div id='ajaxContent'> in the file content.php instead of loading a new page?
I’ve read some about jQuery load but i’m very new to jQuery coding and I cannot figure it out by myself…
You need to preset an javascript var rowId with the id you want to sent via GET to moreData.php. I would set it as rel attribute to the tag and fetch it when I handle the click event.
and then the click event
and in the same event the ajax call
You need jQuery library.