Hello,
I have paging working correctly for my blog.php file. This is displayed when visiting my index.php for the first time. The navigation links on the bottom of the page work fine as well.
There is a left column on the homepage with a search function. You can search for a title in the database. The results of the query are displayed correctly, but I can’t get paging to work correctly.
When I implement paging, the first page of results are displayed correctly including the navigation links on the bottom. When I click on the link NEXT (the one a have been testing with sofar) PHP comes up with 2 errors:
Warning: include(index.php?page=Title_search?start=5) [function.include]: failed to open stream: No error in C:\wamp\www\index.php on line 34
Warning: include() [function.include]: Failed opening ‘index.php?page=Title_search?start=5’ for inclusion (include_path=’.;C:\php\pear’) in C:\wamp\www\index.php on line 34
When hoovering over that link I can see that the link points to the location I expect it to do but the page doesn’t seem to exist.
I have no idea why. I am totally lost. Any help is much appreciated.
My code sofar:
index.php:
[php]
<div id="col1">
<?php
include('col1.php');
// print("tekst voor kolom 1");
?>
</div>
<div id="col2">
<?php
if (!isset($_GET['page']))
{
//url bestaat niet: beginpagina
include('blog.php');
}
else {
if (preg_match('/start/', $_GET['page']))
{
$page = "index.php?page=" . $_GET['page'] ;
include($page);
}
else {
//url bestaat wel: bestand
$page = $_GET['page'].'.php';
if (file_exists($page))
{
//bestand is er, laat zien
include($page);
}
else {
//pagina bestaat niet
echo "$page . 'De opgevraagde pagina bestaat niet.";
}
}
}
?>
</div>
<div id="col3">
<?php
include('col3.php');
?>
</div>
</div>
</div>
</div>
[/php]
The blog.php (which works correctly):
[php]<?php
include(‘Include\function_connect.inc’);
include(‘Include\function_error_msg.inc’);
set_error_handler(“error_msg”);
connect_to_db();
$page_name=“index.php”; // If you use this code with a different page ( or file ) name then change this
if (isset($_GET[‘start’]))
{
$start=$_GET[‘start’];// To take care global variable if OFF
}
else{
$start = 0;
}
$eu = ($start - 0);
$limit = 5; // No of records to be shown per page.
$this_ = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;
$query2 = "select Title, Body, date_format(DatumTijd, 'Geplaatst op %d-%m-%Y om %H:%i uur.')
from blog_artikel ORDER by Art_ID desc";
$result2 = mysql_query($query2);
$row_count = mysql_num_rows($result2);
$query = "select Title, Body, date_format(DatumTijd, 'Geplaatst op %d-%m-%Y om %H:%i uur.')
from blog_artikel ORDER by Art_ID desc limit $eu, $limit ";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result))
{
print("<TABLE>");
print("<TR>");
print("<td class=a>");
print(nl2br($row[0]));
print("</td><td class=b>");
print(nl2br($row[2]));
print("</td>");
print("</TR>");
print("<TR>");
print("<td class=c colspan=2>");
print(nl2br($row[1]));
print("</td>");
print("</TR>");
print("<TR>");
print("<td class=a>");
// print("<TD>" . nl2br($row[$column_num]) . "</TD>");
print("Reactie(X)");
print("</td><td class=b>");
print(" Reageer op deze post");
print("</td>");
print("</TR>");
print("</TABLE>");
?>
<BR>
<?php
echo “
”;
}
print("
");
print “PREV”; $i=0;
echo " $l ";
?>[/php] The Title_search.php (which is driving me crazy): include(‘Include\function_connect.inc’); set_error_handler(“error_msg”); if (isset($_POST[‘Zoeken_titel’]))
if (isset($_GET[‘start’])) $eu = ($start - 0);
print("
|