Reputation: 53
I have created while loop which is used to fetch record matching the word getting from URL. The variable is getting the word but while loop is repeating only one record don't know why? here is my code.
include_once('dbconnect.php');
$GetChR=isset($_REQUEST['authchar'])?$_REQUEST['authchar']:'';
//get the function
include_once ('function.php');[![enter image description here][1]][1]
$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
$limit = 25;
$startpoint = ($page * $limit) - $limit;
//to make pagination
$statement = " table2, table1 WHERE table1.col2 like '%$GetChR%'";
echo '<div class="records round">';
//show records
$query = mysqli_query($con,"SELECT table2.col2 AS a,table1.col2 AS b, table1.col1 AS c, table1.q_url AS d, table1.tags AS e FROM {$statement} LIMIT {$startpoint} , {$limit}");
while ($row = mysqli_fetch_array($query))
{
$input='';
//$Authorname =$row['a'];
$url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$url=explode('/',$url);
echo '<div class="record round">'; $input .='<a href="http://localhost/quotes/'.$url[5].'/'.$row['d'].'.html">';
echo $input .=$row['b'];echo'</a>';echo '</div>';
// $count++;
}
echo'</div>';
echo pagination($statement,$limit,$page);
Upvotes: 1
Views: 163
Reputation: 97120
These are the main issues with your code:
table1
and table2
are to be linked. Results are unpredictable, but would need to see your data to be sure if this is what causes the repeated record.Upvotes: 1