Still battling with this one, but i did find code in another post by charp that works for me if i pare my query down to 'select * from table'. Trouble is my query contains a WHERE clause and whenever I click the 'next' link, the next page contains unfiltered data as if the query had just been SELECT * FROM table.
I'm guessing I somehow need to adapt the echo statement for the links at the end?
Here's charp's code:
Code: Select all
<?php
// Connect to database
$databasename= "XXX";
$username = "XXX";
$table = "XXX";
$password = "XXX";
$db = mysql_connect("$host", "$username", "$password");
mysql_select_db("$databasename", $db);
$num_rows = mysql_num_rows(mysql_query("SELECT * FROM $table"));
$limit = 10; // this many per page
$id=$_GET['id']; // which record to display next
// start with the first row
if (!isset($id)) {
$id=0;
} else {
$id = $id;
}
// grab data from database
$results=mysql_query("SELECT * FROM $table LIMIT $id, $limit");
echo '<table border="1">'."\n";
while($row=mysql_fetch_array($results)) {
$record=$row['id'];
$address=$row["address"];
$city=$row["city"];
echo '<tr><td>'.$record.'</td><td>'.$address.'</td><td>'.$city.'</td></tr>'."\n";
}
echo '</table>';
// show previous link
if ($id>=$limit) {
$prev=$id-$limit;
echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$prev.'">prev</a>';
//i'm guessing the above is what i need to alter?
} else {
echo '<span style="color: #999999;">prev</span>';
}
echo ' ';
// show next link
if ($id<($num_rows - $limit)) {
$next=$id+$limit;
echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$next.'">next</a>';
} else {
echo '<span style="color: #999999;">next</span>';
}
?>
And here's my query:
Code: Select all
$result = mysql_query("SELECT * FROM table WHERE Name LIKE '%$businesstype%' OR (Type LIKE '%$businesstype%' OR Keywords LIKE '%$businesstype%') LIMIT $id, $limit");
Would be eternally indebted for any nuggets of wisdom here. I've been stuck on this for days! in another post by charp that works for me if i pare my query down to 'select * from table'. Trouble is my query contains a WHERE clause and whenever I click the 'next' link, the next page contains unfiltered data as if the query had just been SELECT * FROM table.
I'm guessing I somehow need to adapt the echo statement for the links at the end?
Here's charp's code:
Code: Select all
<?php
// Connect to database
$databasename= "XXX";
$username = "XXX";
$table = "XXX";
$password = "XXX";
$db = mysql_connect("$host", "$username", "$password");
mysql_select_db("$databasename", $db);
$num_rows = mysql_num_rows(mysql_query("SELECT * FROM $table"));
$limit = 10; // this many per page
$id=$_GET['id']; // which record to display next
// start with the first row
if (!isset($id)) {
$id=0;
} else {
$id = $id;
}
// grab data from database
$results=mysql_query("SELECT * FROM $table LIMIT $id, $limit");
echo '<table border="1">'."\n";
while($row=mysql_fetch_array($results)) {
$record=$row['id'];
$address=$row["address"];
$city=$row["city"];
echo '<tr><td>'.$record.'</td><td>'.$address.'</td><td>'.$city.'</td></tr>'."\n";
}
echo '</table>';
// show previous link
if ($id>=$limit) {
$prev=$id-$limit;
echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$prev.'">prev</a>';
//i'm guessing the above is what i need to alter?
} else {
echo '<span style="color: #999999;">prev</span>';
}
echo ' ';
// show next link
if ($id<($num_rows - $limit)) {
$next=$id+$limit;
echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$next.'">next</a>';
} else {
echo '<span style="color: #999999;">next</span>';
}
?>
And here's my query:
Code: Select all
$result = mysql_query("e;SELECT * FROM table WHERE Name LIKE '%$businesstype%' OR (Type LIKE '%$b me if i pare my query down to 'select * from table'. Trouble is my query contains a WHERE clause and whenever I click the 'next' link, the next page contains unfiltered data as if the query had just been SELECT * FROM table.
I'm guessing I somehow need to adapt the echo statement for the links at the end?
Here's charp's code:
Code: Select all
<?php
// Connect to database
$databasename= "e;XXX"e;;
$username = "e;XXX"e;;
$table = "e;XXX"e;;
$password = "e;XXX"e;;
$db = mysql_connect("e;$host"e;, "e;$username"e;, "e;$password"e;);
mysql_select_db("e;$databasename"e;, $db);
$num_rows = mysql_num_rows(mysql_query("e;SELECT * FROM $table"e;));
$limit = 10; // this many per page
$id=$_GETї'id']; // which record to display next
// start with the first row
if (!isset($id)) {
$id=0;
} else {
$id = $id;
}
// grab data from database
$results=mysql_query("e;SELECT * FROM $table LIMIT $id, $limit"e;);
echo '<table border="e;1"e;>'."e;\n"e;;
while($row=mysql_fetch_array($results)) {
$record=$rowї'id'];
$address=$rowї"e;address"e;];
$city=$rowї"e;city"e;];
echo '<tr><td>'.$record.'</td><td>'.$address.'</td><td>'.$city.'</td></tr>'."e;\n"e;;
}
echo '</table>';
// show previous link
if ($id>=$limit) {
$prev=$id-$limit;
echo '<a href="e;'.$_SERVERї'PHP_SELF'].'?id='.$prev.'"e;>prev</a>';
//i'm guessing the above is what i need to alter?
} else {
echo '<span style="e;color: #999999;"e;>prev</span>';
}
echo '&nbsp;&nbsp;&nbsp;&nbsp;';
// show next link
if ($id<($num_rows - $limit)) {
$next=$id+$limit;
echo '<a href="e;'.$_SERVERї'PHP_SELF'].'?id='.$next.'"e;>next</a>';
} else {
echo '<span style="e;color: #999999;"e;>next</span>';
}
?>
And here's my query:
Code: Select all
$re Trouble is my query contains a WHERE clause and whenever I click the 'next' link, the next page contains unfiltered data as if the query had just been SELECT * FROM table.
I'm guessing I somehow need to adapt the echo statement for the links at the end?
Here's charp's code:
Code: Select all
<?php
// Connect to database
$databasename= "e;XXX"e;;
$username = "e;XXX"e;;
$table = "e;XXX"e;;
$password = "e;XXX"e;;
$db = mysql_connect("e;$host"e;, "e;$username"e;, "e;$password"e;);
mysql_select_db("e;$databasename"e;, $db);
$num_rows = mysql_num_rows(mysql_query("e;SELECT * FROM $table"e;));
$limit = 10; // this many per page
$id=$_GETї'id']; // which record to display next
// start with the first row
if (!isset($id)) {
$id=0;
} else {
$id = $id;
}
// grab data from database
$results=mysql_query("e;SELECT * FROM $table LIMIT $id, $limit"e;);
echo '<table border="e;1"e;>'."e;\n"e;;
while($row=mysql_fetch_array($results)) {
$record=$rowї'id'];
$address=$rowї"e;address"e;];
$city=$rowї"e;city"e;];
echo '<tr><td>'.$record.'</td><td>'.$address.'</td><td>'.$city.'</td></tr>'."e;\n"e;;
}
echo '</table>';
// show previous link
if ($id>=$limit) {
$prev=$id-$limit;
echo '<a href="e;'.$_SERVERї'PHP_SELF'].'?id='.$prev.'"e;>prev</a>';
//i'm guessing the above is what i need to alter?
} else {
echo '<span style="e;color: #999999;"e;>prev</span>';
}
echo '&nbsp;&nbsp;&nbsp;&nbsp;';
// show next link
if ($id<($num_rows - $limit)) {
$next=$id+$limit;
echo '<a href="e;'.$_SERVERї'PHP_SELF'].'?id='.$next.'"e;>next</a>';
} else {
echo '<span style="e;color: #999999;"e;>next</span>';
}
?>
And here's my query:
Code: Select all
$result = mysql_query("e;SELECT * FROMelect * from table'. Trouble is my query contains a WHERE clause and whenever I click the 'next' link, the next page contains unfiltered data as if the query had just been SELECT * FROM table.
I'm guessing I somehow need to adapt the echo statement for the links at the end?
Here's charp's code:
Code: Select all
<?php
// Connect to database
$databasename= "XXX";
$username = "XXX";
$table = "XXX";
$password = "XXX";
$db = mysql_connect("$host"e;, "e;$username"e;, "e;$password"e;);
mysql_select_db("e;$databasename"e;, $db);
$num_rows = mysql_num_rows(mysql_query("e;SELECT * FROM $table"e;));
$limit = 10; // this many per page
$id=$_GETї'id']; // which record to display next
// start with the first row
if (!isset($id)) {
$id=0;
} else {
$id = $id;
}
// grab data from database
$results=mysql_query("e;SELECT * FROM $table LIMIT $id, $limit"e;);
echo '<table border="e;1"e;>'."e;\n"e;;
while($row=mysql_fetch_array($results)) {
$record=$rowї'id'];
$address=$rowї"e;address"e;];
$city=$rowї"e;city"e;];
echo '<tr><td>'.$record.'</td><td>'.$address.'</td><td>'.$city.'</td></tr>'."e;\n"e;;
}
echo '</table>';
// show previous link
if ($id>=$limit) {
$prev=$id-$limit;
echo '<a href="e;'.$_SERVERї'PHP_SELF'].'?id='.$prev.'"e;>prev</a>';
//i'm guessing the above is what i need to alter?
} else {
echo '<span style="e;color: #999999;"e;>prev</span>';
}
echo '&nbsp;&nbsp;&nbsp;&nbsp;';
// show next link
if ($id<($num_rows - $limit)) {h this one, but i did find code in another post by charp that works for me if i pare my query down to 'select * from table'. Trouble is my query contains a WHERE clause and whenever I click the 'next' link, the next page contains unfiltered data as if the query had just been SELECT * FROM table.
I'm guessing I somehow need to adapt the echo statement for the links at the end?
Here's charp's code:
Code: Select all
<?php
// Connect to database
$databasename= "XXX";
$username = "XXX";
$table = "XXX";
$password = "XXX";
$db = mysql_connect("$host", "$username", "$password");
mysql_select_db("$databasename", $db);
$num_rows = mysql_num_rows(mysql_query("SELECT * FROM $table"));
$limit = 10; // this many per page
$id=$_GET['id']; // which record to display next
// start with the first row
if (!isset($id)) {
$id=0;
} else {
$id = $id;
}
// grab data from database
$results=mysql_query("SELECT * FROM $table LIMIT $id, $limit");
echo '<table border="1">'."\n";
while($row=mysql_fetch_array($results)) {
$record=$row['id'];
$address=$row["address"];
$city=$row["city"];
echo '<tr><td>'.$record.'</td><td>'.$address.'</td><td>'.$city.'</td></tr>'."\n";
}
echo '</table>';
// show previous link
if ($id>=$limit) {
$prev=$id-$limit;
echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$prev.'">prev</a>';
//i'm guessing the above is what i need to alter?
} else {
echo '<span style="color: #999999;">prev</span>';
}
echo ' ';
// show next link
if ($id<($num_rows - $limit)) {
$next=$id+$limit;
echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$next.'">next</a>';
} else {
echo '<span style="color: #999999;">next</span>';
}
?>
And here's my query:
Code: Select all
$result = mysql_query("SELECT * FROM table WHERE Name LIKE '%$businesstype%' OR (Type LIKE '%$businesstype%' OR Keywords LIKE '%$businesstype%') LIMIT $id, $limit");
Would be eternally indebted for ah this one, but i did find code in another post by charp that works for me if i pare my query down to 'select * from table'. Trouble is my query contains a WHERE clause and whenever I click the 'next' link, the next page contains unfiltered data as if the query had just been SELECT * FROM table.
I'm guessing I somehow need to adapt the echo statement for the links at the end?
Here's charp's code:
Code: Select all
<?php
// Connect to database
$databasename= "XXX";
$username = "XXX";
$table = "XXX";
$password = "XXX";
$db = mysql_connect("$host", "$username", "$password");
mysql_select_db("$databasename", $db);
$num_rows = mysql_num_rows(mysql_query("SELECT * FROM $table"));
$limit = 10; // this many per page
$id=$_GET['id']; // which record to display next
// start with the first row
if (!isset($id)) {
$id=0;
} else {
$id = $id;
}
// grab data from database
$results=mysql_query("SELECT * FROM $table LIMIT $id, $limit");
echo '<table border="1">'."\n";
while($row=mysql_fetch_array($results)) {
$record=$row['id'];
$address=$row["address"];
$city=$row["city"];
echo '<tr><td>'.$record.'</td><td>'.$address.'</td><td>'.$city.'</td></tr>'."\n";
}
echo '</table>';
// show previous link
if ($id>=$limit) {
$prev=$id-$limit;
echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$prev.'">prev</a>';
//i'm guessing the above is what i need to alter?
} else {
echo '<span s;quote;XXX";
$db = mysql_connect("$host", "$username", "$password");
mysql_select_db("$databasename", $db);
$num_rows = mysql_num_rows(mysql_query("SELECT * FROM $table"));
$limit = 10; // this many per page
$id=$_GET['id']; // which record to display next
// start with the first row
if (!isset($id)) {
$id=0;
} else {
$id = $id;
}
// grab data from database
$results=mysql_query("SELECT * FROM $table LIMIT $id, $limit");
echo '<table border="1">'."\n";
while($row=mysql_fetch_array($results)) {
$record=$row['id'];
$address=$row["address"];
$city=$row["city"];
echo '<tr><td>'.$record.'</td><td>'.$address.'</td><td>'.$city.'</td></tr>'."\n";
}
echo '</table>';
// show previous link
if ($id>=$limit) {
$prev=$id-$limit;
echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$prev.'">prev</a>';
//i'm guessing the above is what i need to alter?
} else {
echo '<span style="color: #999999;">prev</span>';
}
echo ' ';
// show next link
if ($id<($num_rows - $limit)) {
$next=$id+$limit;
echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$next.'">next</a>';
} else {
echo '<span style="color: #999999;">next</span>';
}
?>
And here's my query:
Code: Select all
$result = mysql_query("SELECT * FROM table WHERE Name LIKE '%$businesstype%' OR (Type LIKE '%$businesstype%' OR Keywords LIKE '%$businesstype%') LIMIT $id, $limit");
Would be eternally indebted for any nuggets of wisdom here. I've been stuck on this for days!("SELECT * FROM $table"));
$limit = 10; // this many per page
$id=$_GET['id']; // which record to display next
// start with the first row
if (!isset($id)) {
$id=0;
} else {
$id = $id;
}
// grab data from database
$results=mysql_query("SELECT * FROM $table LIMIT $id, $limit");
echo '<table border="1">'."\n";
while($row=mysql_fetch_array($results)) {
$record=$rowї'id'];
$address=$rowї"e;address"e;];
$city=$rowї"e;city"e;];
echo '<tr><td>'.$record.'</td><td>'.$address.'</td><td>'.$city.'</td></tr>'."e;\n"e;;
}
echo '</table&r me if i pare my query down to 'select * from table'. Trouble is my query contains a WHERE clause and whenever I click the 'next' link, the next page contains unfiltered data as if the query had just been SELECT * FROM table.
I'm guessing I somehow need to adapt the echo statement for the links at the end?
Here's charp's code:
Code: Select all
<?php
// Connect to database
$databasename= "XXX";
$username = "XXX";
$table = "XXX";
$password = "XXX";
$db = mysql_connect("$host", "$username", "$password");
mysql_select_db("$databasename"e;, $db);
$num_rows = mysql_num_rows(mysql_query("e;SELECT * FROM $table"e;));
$limit = 10; // this many per page
$id=$_GETї'id']; // which record to display next
// start with the first row
if (!isset($id)) {
$id=0;
} else {
$id = $id;
}
// grab data from database
$results=mysql_query("e;SELECT * FROM $table LIMIT $id, $limit"e;);
echo '<table border="e;1"e;>'."e;\n"e;;
while($row=mysql_fetch_array($results)) {
$record=$rowї'id'];
$address=$rowї"e;address"e;];
$city=$rowї"e;city"e;];
echo '<tr><td>'.$record.'</td><td>'.$address.'</td><td>'.$city.'</td></tr>'."e;\n"e;;
}
echo '</table>';
// show previous link
if ($id>=$limit) {
$prev=$id-$limit;
echo '<a href="e;'.$_SERVERї'PHP_SELF'].'?id='.$prev.'"e;>prev</a>';
//i'm guessing the above is what i need to alter?
} else {
echo '<span style="e;color: #999999;"e;>prev</span>';
}
echo '&nbsp;&nbsp;&nbsp;&nbsp;';
// show next link
if ($id&l down to 'select * from table'. Trouble is my query contains a WHERE clause and whenever I click the 'next' link, the next page contains unfiltered data as if the query had just been SELECT * FROM table.
I'm guessing I somehow need to adapt the echo statement for the links at the end?
Here's charp's code:
Code: Select all
<?php
// Connect to database
$databasename= "e;XXX"e;;
$username = "e;XXX"e;;
$table = "e;XXX"e;;
$password = "e;XXX"e;;
$db = mysql_connect("e;$host"e;, "e;$username"e;, "e;$password"e;);
mysql_select_db("e;$databasename"e;, $db);
$num_rows = mysql_num_rows(mysql_query("e;SELECT * FROM $table"e;));
$limit = 10; // this many per page
$id=$_GETї'id']; // which record to display next
// start with the first row
if (!isset($id)) {
$id=0;
} else {
$id = $id;
}
// grab data from database
$results=mysql_query("e;SELECT * FROM $table LIMIT $id, $limit"e;);
echo '<table border="e;1"e;>'."e;\n"e;;
while($row=mysql_fetch_array($results)) {
$record=$rowї'id'];
$address=$rowї"e;address"e;];
$city=$rowї"e;city"e;];
echo '<tr><td>'.$record.'</td><td>'.$address.'</td><td>'.$city.'</td></tr>'."e;\n"e;;
}
echo '</table>';
// show previous link
if ($id>=$limit) {
$prev=$id-$limit;
echo '<a href="e;'.$_SERVERї'PHP_SELF'].'?id='.$prev.'"e;>prev</a>';
//i'm guessing the above is what i need to alter?
} else {
echo '<span style="e;color: #999999;"e;>prev</span>';
}
echo '&nbsp;&nbsp;&nbsp;&nbsp;';
// show next link
if ($id<($num_rows - $limit)) {
$next=$id+$limit;
echo '<a href="e;'.$_SERVERї'PHP_SELF'].'?id='.$next.'"e;>next</a>';
} else {
echo '<span style="e;color: #999999;"her post by charp that works for me if i pare my query down to 'select * from table'. Trouble is my query contains a WHERE clause and whenever I click the 'next' link, the next page contains unfiltered data as if the query had just been SELECT * FROM table.
I'm guessing I somehow need to adapt the echo statement for the links at the end?
Here's charp's code:
Code: Select all
<?php
// Connect to database
$databasename= "e;XXX"e;;
$username = "e;XXX"e;;
$table = "XXX";
$password = "XXX";
$db = mysql_connect("$host", "$username", "$password");
mysql_select_db("$databasename", $db);
$num_rows = mysql_num_rows(mysql_query("SELECT * FROM $table"));
$limit = 10; // this many per page
$id=$_GET['id']; // which record to display next
// start with the first row
if (!isset($id)) {
$id=0;
} else {
$id = $id;
}
// grab data from database
$results=mysql_query("e;SELECT * FROM $table LIMIT $id, $limit"e;);
echo '<table border="e;1"e;>'."e;\n"e;;
while($row=mysql_fetch_array($results)) {
$record=$rowї'id'];
$address=$rowї"e;address"e;];
$city=$rowї"e;city"e;];
echo '<tr><td>'.$record.'</td><td>'.$address.'</td><td>'.$city.'</td></tr>'."e;\n"e;;
}
echo '</table>';
// show previous link
if ($id>=$limit) {
$prev=$id-$limit;
echo '<a href="e;'.$_SERVERї'PHP_SELF'].'?id='.$prev.'"e;>prev</a>';
//i'm guessing the above is what i need to alter?
} else {
echo '&he 'next' link, the next page contains unfiltered data as if the query had just been SELECT * FROM table.
I'm guessing I somehow need to adapt the echo statement for the links at the end?
Here's charp's code:
Code: Select all
<?php
// Connect to database
$databasename= "e;XXX"e;;
$username = "e;XXX"e;;
$table = "e;XXX"e;;
$password = "e;XXX"e;;
$db = mysql_connect("e;$host"e;, "e;$username"e;, "e;$password"e;);
mysql_select_db("e;$databasename"e;, $db);
$num_rows = mysql_num_rows(mysql_query("e;SELECT * FROM $table"e;));
$limit = 10; // this many per page
$id=$_GETї'id']; // which record to display next
// start with the first row
if (!isset($id)) {
$id=0;
} else {
$id = $id;
}
// grab data from database
$results=mysql_query("e;SELECT * FROM $table LIMIT $id, $limit"e;);
echo '<table border="e;1"e;>'."e;\n"e;;
while($row=mysql_fetch_array($results)) {
$record=$rowї'id'];
$address=$rowї"e;address"e;];
$city=$rowї"e;city"e;];
echo '<tr><td>'.$record.'</td><td>'.$address.'</td><td>'.$city.'</td></tr>'."e;\n"e;;
}
echo '</table>';
// show previous link
if ($id>=$limit) {
$prev=$id-$limit;
echo '<a href="e;'.$_SERVERї'PHP_SELF'].'?id='.$prev.'"e;>prev</a>';
//i'm guessing the above is what i need to alter?
} else {
echo '<span style="e;color: #999999;"e;>prev</span>';
}
echo '&nbsp;&nbsp;&nbsp;&nbsp;';
// show next link
if ($id<($num_rows - $limit)) {
$next=$id+$limit;
echo '<a href="e;'.$_SERVERї'PHP_SELF'].'?id='.$next.'"e;>next</a>';
} else {
echo '<span style="e;color: #999999;"e;>next</span>';
}
?>
And here's my query:
Code: Select all
$result = mysql_query("SELECT * FROM table WHERE Name LIKE '%$businesstype%' OR (Type LIKE '%$businesstype%' OR Keywords LIKE '%$businesstype%') LIMIT $id, $limit");
Would be eter for the links at the end?
Here's charp's code:
Code: Select all
<?php
// Connect to database
$databasename= "XXX";
$username = "XXX";
$table = "XXX";
$password = "XXX";
$db = mysql_connect("$host", "$username", "$password");
mysql_select_db("$databasename", $db);
$num_rows = mysql_num_rows(mysql_query("SELECT * FROM $table"));
$limit = 10; // this many per page
$id=$_GETї'id']; // which record to display next
// start with the first row
if (!isset($id)) {
$id=0;
} else {
$id = $id;
}
// grab data from database
$results=mysql_query("e;SELECT * FROM $table LIMIT $id, $limit"e;);
echo '<table border="e;1"e;>'."e;\n"e;;
while($row=mysql_fetch_array($results)) {
$record=$rowї'id'];
$address=$rowї"e;address"e;];
$city=$rowї"e;city"e;];
echo '<tr><td>'.$record.'</td><td>'.$address.'</td><td>'.$city.'</td></tr>'."e;\n"e;;
}
echo '</table>';
// show previous link
if ($id>=$limit) {
$prev=$id-$limit;
echo '<a href="e;'.$_SERVERї'PHP_SELF'].'?id='.$prev.'"e;>prev</a>';
//i'm guessing the above is what i need to alter?
} else {
echo '<sput i did find code in another post by charp that works for me if i pare my query down to 'select * from table'. Trouble is my query contains a WHERE clause and whenever I click the 'next' link, the next page contains unfiltered data as if the query had just been SELECT * FROM table.
I'm guessing I somehow need to adapt the echo statement for the links at the end?
Here's charp's code:
Code: Select all
<?php
// Connect to database
$databasename= "XXX";
$username = "XXX";
$table = "XXX";
$password = "XXX";
$db = mysql_connect("$host", "$username", "$password");
mysql_select_db("$databasename", $db);
$num_rows = mysql_num_rows(mysql_query("SELECT * FROM $table"));
$limit = 10; // this many per page
$id=$_GET['id']; // which record to display next
// start with the first row
if (!isset($id)) {
$id=0;
} else {
$id = $id;
}
// grab data from database
$results=mysql_query("SELECT * FROM $table LIMIT $id, $limit");
echo '<table border="1">'."\n";
while($row=mysql_fetch_array($results)) {
$record=$row['id'];
$address=$row["address"];
$city=$row["city"];
echo '<tr><td>'.$record.'</td><td>'.$address.'</td>&the query had just been SELECT * FROM table.
I'm guessing I somehow need to adapt the echo statement for the links at the end?
Here's charp's code:
Code: Select all
<?php
// Connect to database
$databasename= "XXX";
$username = "XXX";
$table = "XXX";
$password = "XXX";
$db = mysql_connect("$host", "$username", "$password");
mysql_select_db("$databasename", $db);
$num_rows = mysql_num_rows(mysql_query("SELECT * FROM $table"));
$limit = 10; // this many per page
$id=$_GET['id']; // which record to display next
// start with the first row
if (!isset($id)) {
$id=0;
} else {
$id = $id;
}
// grab data from database
$results=mysql_query("SELECT * FROM $table LIMIT $id, $limit");
echo '<table border="1">'."\n";
while($row=mysql_fetch_array($results)) {
$record=$row['id'];
$address=$row["address"];
$city=$row["city"];
echo '<tr><td>'.$record.'</td><td>'.$address.'</td><td>'.$city.'</td></tr>'."\n";
}
echo '</table>';
// show previous link
if ($id>=$limit) {
$prev=$id-$limit;
echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$prev.'">prev</a>';
//i'm guessing the above is what i need to alter?
} else {
echo '<span style="color: #999999;">prev</span>';
}
echo ' ';
// show next link
if ($id<($num_rows - $limit)) {
$next=$id+$limit;
echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$next.'">next</a>';
} else {
echo '<span style="color: #999999;">next</span>';
}
?>
And here's my query:
Code: Select all
$result = mysql_query("SELECT * FROM table WHERE Name LIKE '%$businesstype%' OR (Type LIKE '%$businesstype%' OR Keywords LIKE '%$businesstype%') LIMIT $id, $limit");
Would be eternally indebted for any nuggets of wisdom here. I've been d?
Here's charp's code:
Code: Select all
<?php
// Connect to database
$databasename= "XXX";
$username = "XXX";
$table = "XXX";
$password = "XXX";
$db = mysql_connect("$host", "$username", "$password");
mysql_select_db("$databasename", $db);
$num_rows = mysql_num_rows(mysql_query("SELECT * FROM $table"));
$limit = 10; // this many per page
$id=$_GET['id']; // which record to display next
// start with the first row
if (!isset($id)) {
$id=0;
} else {
$id = $id;
}
// grab data from database
$results=mysql_query("SELECT * FROM $table LIMIT $id, $limit");
echo '<table border="1">'."\n";
while($row=mysql_fetch_array($results)) {
$record=$row['id'];
$address=$row["address"];
$city=$row["city"];
echo '<tr><td>'.$record.'</td><td>'.$address.'</td><td>'.$city.'</td></tr>'."\n";
}
echo '</table>';
// show previous link
if ($id>=$limit) {
$prev=$id-$limit;
echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$prev.'">prev</a>';
//i'm guessing the above is what i need to alter?
} else {
echo '<span style="color: #999999;">prev</span>';
}
echo ' ';
// show next link
if ($id<($num_rows - $limit)) {
$next=$id+$limit;
echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$next.'">next</a>';
} else {
echo '<span style="color: #999999;">next</span>';
}
?>
And here's my query:
Code: Select all
$result = mysql_query("SELECT * FROM table WHERE Name LIKE '%$businesstype%' OR (Type LIKE '%$businesstype%' OR Keywords LIKE '%$businesstype%') LIMIT $id, $limit");
Would be eternally indebted for any nuggets of wisdom here. I've been stuck on this for days!databasename", $db);
$num_rows = mysql_num_rows(mysql_query("SELECT * FROM $table"));
$limit = 10; // this many per page
$id=$_GET['id']; // which record to display next
// start with the first row
if (!isset($id)) {
$id=0;
} else {
$id = $id;
}
// grab data from database
$results=mysql_query("SELECT * FROM $table LIMIT $id, $limit");
echo '<table border="1">'."\n";
while($row=mysql_fetch_array($results)) {
$record=$row['id'];
$address=$row["address"];
$city=$row["city"];
echo '<tr><td>'.$record.'</td><td>'.$address.'</td><td>'.$city.'</td></tr>'."\n";
}
echo '</table>';
// show previous link
if ($id>=$limit) {
$prev=$id-$limit;
echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$prev.'">prev</a>';
//i'm guessing the above is what i need to alter?
} else {
echo '<span style="color: #999999;">prev</span>';
}
echo ' ';
// show next link
if ($id<($num_rows - $limit)) {
$next=$id+$limit;
echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$next.'">next</a>';
} else {
echo '<span style="color: #999999;">next</span>';
}
?>
And here's my query:
Code: Select all
$result = mysql_query("SELECT * FROM table WHERE Name LIKE '%$businesstype%' OR (Type LIKE '%$businesstype%' OR Keywords LIKE '%$businesstype%') LIMIT $id, $limit");
Would be eternally indnk, the next page contains unfiltered data as if the query had just been SELECT * FROM table.
I'm guessing I somehow need to adapt the echo statement for the links at the end?
Here's charp's code:
Code: Select all
<?php
// Connect to database
$databasename= "XXX";
$username = "XXX";
$table = "XXX";
$password = "XXX";
$db = mysql_connect("$host", "$username", "$password");
mysql_select_db("$databasename", $db);
$num_rows = mysql_num_rows(mysql_query("SELECT * FROM $table"));
$limit = 10; // this many per page
$id=$_GET['id']; // which record to display next
// start with the first row
if (!isset($id)) {
$id=0;
} else {
$id = $id;
}
// grab data from database
$results=mysql_query("SELECT * FROM $table LIMIT $id, $limit");
echo '<table border="1">'."\n";
while($row=mysql_fetch_array($results)) {
$record=$row['id'];
$address=$row["address"];
$city=$row["city"];
echo '<tr><td>'.$record.'</td><td>'.$address.'</td><td>'.$city.'</td></tr>'."\n";
}
echo '</table>';
// show previous link
if ($id>=$limit) {
$prev=$id-$limit;
echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$prev.'">prev</a>';
//i'm guessing the above is what i need to alter?
} else {
echo '<span style="color: #999999;">prev</span>';
}
echo ' ';
// show next link
if ($id<($num_rows - $limit)) {
$next=$id+$limit;
echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$next.'">next</a>';
} else {
echo '<span style="color: #999999;">next</span>';
}
?>
And here's my query:
Code: Select all
$result = mysql_query("e;SELECT * FROM table WHERE Name LIKE '%$businesstype%' OR (Type LIKE '%$buLECT * FROM table.
I'm guessing I somehow need to adapt the echo statement for the links at the end?
Here's charp's code:
Code: Select all
<?php
// Connect to database
$databasename= "XXX";
$username = "XXX";
$table = "XXX";
$password = "XXX";
$db = mysql_connect("$host", "$username", "$password");
mysql_select_db("$databasename", $db);
$num_rows = mysql_num_rows(mysql_query("SELECT * FROM $table"));
$limit = 10; // this many per page
$id=$_GETї'id']; // which record to display next
// start with the first row
if (!isset($id)) {
$id=0;
} else {
$id = $id;
}
// grab data from database
$results=mysql_query("e;SELECT * FROM $table LIMIT $id, $limit"e;);
echo '<table border="e;1"e;>'."e;\n"e;;
while($row=mysql_fetch_array($results)) {
$record=$rowї'id'];
$address=$rowї"e;address"e;];
$city=$rowї"e;city"e;];
echo '<tr><td>'.$record.'</td><td>'.$address.'</td><td>'.$city.'</td></tr>'."e;\n"e;;
}
echo '</table>';
// show previous link
if ($id>=$limit) {
$prev=$id-$limit;
echo '<a href="e;'.$_SERVERї'PHP_SELF'].'?id='.$prev.'"e;>prev</a>';
//i'm guessing the above is what i need to alter?
} else {
echo '<span style="e;color: #999999;"e;>prev</span>';
}
echo '&nbsp;&nbsp;&nbsp;&nbsp;';
// show next link
if ($id<($num_rows - $limit)) {
$next=$id+$limit;
echo '<a href="e;'.$_SERVERї'PHP_SELF'].'?id='.$next.'"e;>next</a>';
} else {
echo '<span style="e;color: #999999;"e;>next</span>';
}
?>
[XXX";
$password = "XXX";
$db = mysql_connect("$host", "$username", "$password");
mysql_select_db("$databasename", $db);
$num_rows = mysql_num_rows(mysql_query("SELECT * FROM $table"));
$limit = 10; // this many per page
$id=$_GET['id']; // which record to display next
// start with the first row
if (!isset($id)) {
$id=0;
} else {
$id = $id;
}
// grab data from database
$results=mysql_query("SELECT * FROM $table LIMIT $id, $limit");
echo '<table border="e;1"e;>'."e;\n"e;;
while($row=mysql_fetch_array($results)) {
$record=$rowї'id'];
$address=$rowї"e;address"e;];
$city=$rowї"e;city"e;];
echo '<tr><td>'.$record.'</td><td>'.$address.'</td><td>'.$city.'</td></tr>'."e;\n"e;;
}
echo '</table>';
// show previouh this one, but i did find code in another post by charp that works for me if i pare my query down to 'select * from table'. Trouble is my query contains a WHERE clause and whenever I click the 'next' link, the next page contains unfiltered data as if the query had just been SELECT * FROM table.
I'm guessing I somehow need to adapt the echo statement for the links at the end?
Here's charp's code:
Code: Select all
<?php
// Connect to database
$databasename= "XXX";
$username = "XXX";
$table = "XXX";
$password = "XXX";
$db = mysql_connect("$host", "$username", "$password");
mysql_select_db("$databasename", $db);
$num_rows = mysql_num_rows(mysql_query("SELECT * FROM $table"));
$limit = 10; // this many per page
$id=$_GET['id']; // which record to display next
// start with the first row
if (!isset($id)) {
$id=0;
} else {
$id = $id;
}
// grab data from database
$results=mysql_query("SELECT * FROM $table LIMIT $id, $limit");
echo '<table border="1">'."\n";
while($row=mysql_fetch_array($results)) {
$record=$row['id'];
$address=$row["address"];
$city=$row["city"];
echo '<tr><td>'.$record.'</td><td>'.$address.'</td><td>'.$city.'</td></tr>'."\n";
}
echo '</table>';
// show previous link
if ($id>=$limit) {
$prev=$id-$limit;
echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$prev.'">prev</a>';
//i'm guessing the above is what i need to alter?
} else {
echo '<span style="color: #999999;">prev</span>';
}
echo ' ';
// show next link
if ($id<($num_rows - $limit)) {
$next=$id+$limit;
echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$next.'">next</a>';
} else {
echo '<span style="color: #999999;">next</span&g
<?php
// Connect to database
$databasename= "XXX";
$username = "XXX";
$table = "XXX";
$password = "XXX";
$db = mysql_connect("$host", "$username", "$password");
mysql_select_db("$databasename", $db);
$num_rows = mysql_num_rows(mysql_query("SELECT * FROM $table"));
$limit = 10; // this many per page
$id=$_GET['id']; // which record to display next
// start with the first row
if (!isset($id)) {
$id=0;
} else {
$id = $id;
}
// grab data from database
$results=mysql_query("SELECT * FROM $table LIMIT $id, $limit");
echo '<table border="1">'."\n";
while($row=mysql_fetch_array($results)) {
$record=$row['id'];
$address=$row["address"];
$city=$row["city"];
echo '<tr><td>'.$record.'</td><td>'.$address.'</td><td>'.$city.'</td></tr>'."\n";
}
echo '</table>';
// show previous link
if ($id>=$limit) {
$prev=$id-$limit;
echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$prev.'">prev</a>';
//i'm guessing the above is what i need to alter?
} else {
echo '<span style="color: #999999;">prev</span>';
}
echo ' ';
// show next link
if ($id<($num_rows - $limit)) {
$next=$id+$limit;
echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$next.'">next</a>';
} else {
echo '<span style="color: #999999;">next</span>';
}
?>
And here's my query:
Code: Select all
$result = mysql_query("SELECT * FROM table WHERE Name LIKE '%$businesstype%' OR (Type LIKE '%$businesstype%' OR Keywords LIKE '%$businesstype%') LIMIT $id, $limit");
Would be eternally indebted for any nuggets of wisdom here. I've been stuck on this for days!