Hi all,
I have created a script where the user can choose to query the database. I devided the screen my means of a table into 2 parts. I want to display the result of the query in the second part of the table. So far so good BUT i want to be able to "browse" through the data. I tried to implement it but I can't get it going in my script. Can anyone help me with this ?
I created the anchor for The next and previous but it ends there :-(
This is the code
<?php
session_start();
require_once('functions.php');
$thispage = $_SERVER['PHP_SELF'];
if (($_POST['query'] == 'Query') or (isset($_POST['page'])))
{
$records_on_page = 20;
$current_page = 1;
$keuze = $_POST['selectie'];
$waarde = $_POST['waarde'];
$offset = 0;
$count_query = "SELECT count(*) from naw";
$rh = mysql_query($count_query);
list ($record_count) = mysql_fetch_array($rh);
$max_pages = floor($record_count / $records_on_page);
if ($keuze == "plaats")
{
$querystring ="select * from naw where plaats = '$waarde' limit $offset,$records_on_page ";
}
if ($keuze == "naam")
{
$querystring = "SELECT * FROM naw WHERE achternaam = '$waarde'";
}
if ($keuze == "postcode")
{
$querystring = "SELECT * FROM naw WHERE postcode = '$waarde'";
}
if ($keuze == "studierichting")
{
$querystring = "SELECT studie_instelling,studie_richting,studie_einde,promotiedatum,naw.*
FROM naw_totaal inner join naw on naw_totaal.idnr = naw.idnr WHERE naw_totaal.studie_richting = '$waarde'";
}
$_POST['$page'] = 1;
$table_params = "WIDTH = '100%' BORDER = '1'";
$disp = display_db_query($querystring,'1',$table_params,$offset);
$disp .= "<br> <a href='$thispage' ?page=' . ($current_page - 1) . '>Vorige 20</a>";
$disp .= "     <a href='$thispage' ?page=' . ($current_page + 1) . '>Volgende 20</a>";
}
ELSE
{
$disp="Nog geen uitvoer";
}
include("header.php");
$form_page = <<< QUERYPAGE
<HTML><HEAD></HEAD>
<BODY>
<FORM METHOD=POST ACTION = "$thispage">
<TABLE WIDTH="100%" BORDER="2">
<TR>
<p>Welke selectie wilt u opstarten</p>
<fieldset><legend></legend>
<p><input type ="radio" name="selectie" value="plaats" id="selplaats"> <label for="selplaats">Plaats</label><br>
<p><input type ="radio" name="selectie" value="naam" id="selnaam"> <label for="selnaam">Naam</label><br>
<p><input type ="radio" name="selectie" value="postcode" id="selpostcode"> <label for="selpostcode">Postcode</label><br>
<p><input type ="radio" name="selectie" value="studierichting" id="selstudierichting"> <label for="selstudierichting">Studierichting</label><br>
<p> waarde : <input type ="text" name="waarde" size = "30"><br>
<input type="submit" name="query" value="Query">
</TR></TABLE>
<TABLE WIDTH="100%" BORDER="2">
<TR><TD>
$disp;
</TD></FORM></BODY></HTML>
QUERYPAGE;
ECHO $form_page
?>
I have created a script where the user can choose to query the database. I devided the screen my means of a table into 2 parts. I want to display the result of the query in the second part of the table. So far so good BUT i want to be able to "browse" through the data. I tried to implement it but I can't get it going in my script. Can anyone help me with this ?
I created the anchor for The next and previous but it ends there :-(
This is the code
<?php
session_start();
require_once('functions.php');
$thispage = $_SERVER['PHP_SELF'];
if (($_POST['query'] == 'Query') or (isset($_POST['page'])))
{
$records_on_page = 20;
$current_page = 1;
$keuze = $_POST['selectie'];
$waarde = $_POST['waarde'];
$offset = 0;
$count_query = "SELECT count(*) from naw";
$rh = mysql_query($count_query);
list ($record_count) = mysql_fetch_array($rh);
$max_pages = floor($record_count / $records_on_page);
if ($keuze == "plaats")
{
$querystring ="select * from naw where plaats = '$waarde' limit $offset,$records_on_page ";
}
if ($keuze == "naam")
{
$querystring = "SELECT * FROM naw WHERE achternaam = '$waarde'";
}
if ($keuze == "postcode")
{
$querystring = "SELECT * FROM naw WHERE postcode = '$waarde'";
}
if ($keuze == "studierichting")
{
$querystring = "SELECT studie_instelling,studie_richting,studie_einde,promotiedatum,naw.*
FROM naw_totaal inner join naw on naw_totaal.idnr = naw.idnr WHERE naw_totaal.studie_richting = '$waarde'";
}
$_POST['$page'] = 1;
$table_params = "WIDTH = '100%' BORDER = '1'";
$disp = display_db_query($querystring,'1',$table_params,$offset);
$disp .= "<br> <a href='$thispage' ?page=' . ($current_page - 1) . '>Vorige 20</a>";
$disp .= "     <a href='$thispage' ?page=' . ($current_page + 1) . '>Volgende 20</a>";
}
ELSE
{
$disp="Nog geen uitvoer";
}
include("header.php");
$form_page = <<< QUERYPAGE
<HTML><HEAD></HEAD>
<BODY>
<FORM METHOD=POST ACTION = "$thispage">
<TABLE WIDTH="100%" BORDER="2">
<TR>
<p>Welke selectie wilt u opstarten</p>
<fieldset><legend></legend>
<p><input type ="radio" name="selectie" value="plaats" id="selplaats"> <label for="selplaats">Plaats</label><br>
<p><input type ="radio" name="selectie" value="naam" id="selnaam"> <label for="selnaam">Naam</label><br>
<p><input type ="radio" name="selectie" value="postcode" id="selpostcode"> <label for="selpostcode">Postcode</label><br>
<p><input type ="radio" name="selectie" value="studierichting" id="selstudierichting"> <label for="selstudierichting">Studierichting</label><br>
<p> waarde : <input type ="text" name="waarde" size = "30"><br>
<input type="submit" name="query" value="Query">
</TR></TABLE>
<TABLE WIDTH="100%" BORDER="2">
<TR><TD>
$disp;
</TD></FORM></BODY></HTML>
QUERYPAGE;
ECHO $form_page
?>