Hello, I have been trying to get the id of a button(in this case a link) with jquery and send the id or class name to a php script so I can enter that id or class name in a sql query. I thought that this would be the easiest thing to do, but it has turned out to be the most difficult thing since nothing seems to work.
I have on one page a link:
pagination.php:
<a href="#" class="category" id="marketing">Marketing</a>
then another script for the jquery (when the button is clicked):
jquery_pagination.php:
$("#pagination a#marketing").click(function () {
Display_Load();
var pageNum = $('#content').attr('data-page');
$("#content").load("filter_marketing.php?page=" + pageNum, Hide_Load());
});
And lastly, the php page where I want the 'marketing' id to go:
filter_marketing.php:
<?php
include('config.php');
$per_page = 3;
if($_GET)
{
$page=$_GET['page'];
}
$start = ($page-1)*$per_page;
//$sql = "select * from explore order by id limit $start,$per_page";
$sql = "SELECT * FROM explore WHERE category='marketing' ORDER BY category LIMIT $start,$per_page";
$result = mysql_query($sql);
?>
<table width="800px">
<?php
while($row = mysql_fetch_array($result))
{
$msg_id=$row['id'];
$message=$row['site_description'];
$site_price=$row['site_price'];
?>
<tr>
<td><?php echo $msg_id; ?></td>
<td><?php echo $message; ?></td>
<td><?php echo $site_price; ?></td>
</tr>
<?php
}
?>
</table>
So all I want is to automatically place the id of 'marketing' in the sql query instead of hard coded as seen here:
$sql = "SELECT * FROM explore WHERE category='marketing' ORDER BY category LIMIT $start,$per_page";
If anyone can help on this that would be amazing.
Thank you.