Code: Select all
$start = $_GETї"id"];Code: Select all
$category = $_GETї"category"];Code: Select all
$sql = "SELECT id, title FROM userjokes WHERE category='.$category' LIMIT " .$start. ", " .$records; //notice category=''something.php?id=1&category=string
The id is an integer and the category is a string. How would I do this, just put it in the code (look below), or do i have to add something else?
Here is the ORIGINAL CODE that works (just with $start (id))
Code: Select all
<HTML>
<body>
<script type="text/javascript">
function popup_all(id)
{
window.open("archive2.php?id=" + id, "window_name", "0","0","0","0","yes","yes","200","300");
}
</script>
<?php
$db = mysql_connect("localhost","","");
mysql_select_db("",$db);;
$callsign = $HTTP_POST_VARSї'id'];
$records = 10; // Number of records per page
$start = $_GETї"id"]; // Get "id" value from address line
if ($start == NULL) // No address line variable
{
$start = 0; // Default value
}
$sql = "SELECT id, title FROM userjokes WHERE category='something' LIMIT " .$start. ", " .$records;
$result=mysql_query ($sql, $db) or die($sql.' :'.mysql_error());
while ($row = mysql_fetch_object ($result))
{
print("<td><a href="javascript:popup_all($row->id)">$row->title</a></td>");
}
// Add number of records per page to starting value to get records for next page
$next = $start + $records;
echo '<form method="GET" action="', $_SERVERї'PHP_SELF'], '">';
echo '<input type="hidden" name="id" value="', $next, '" />';
print("<input type="submit" value="Next">");
print("</form>");
?>Code: Select all
<HTML>
<body>
<script type="text/javascript">
function popup_all(id)
{
window.open("archive2.php?id=" + id, "window_name", "0","0","0","0","yes","yes","200","300");
}
</script>
<?php
$db = mysql_connect("localhost","","");
mysql_select_db("",$db);;
$callsign = $HTTP_POST_VARSї'id'];
$records = 10; // Number of records per page
$start = $_GETї"id"]; // Get "id" value from address line
$category = $_GETї"category"];
if ($start == NULL) // No address line variable
{
$start = 0; // Default value
}
$sql = "SELECT id, title FROM userjokes WHERE category='.$category' LIMIT " .$start. ", " .$records;
$result=mysql_query ($sql, $db) or die($sql.' :'.mysql_error());
while ($row = mysql_fetch_object ($result))
{
print("<td><a href="javascript:popup_all($row->id)">$row->title</a></td>");
}
// Add number of records per page to starting value to get records for next page
$next = $start + $records;
echo '<form method="GET" action="', $_SERVERї'PHP_SELF'], '">';
echo '<input type="hidden" name="id" value="', $next, '" />';
print("<input type="submit" value="Next">");
print("</form>");
?>Thanks.