Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limit records on screen made up by a table

Status
Not open for further replies.

OldSmelly

Programmer
Nov 22, 2001
70
NL
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 .= "&nbsp&nbsp&nbsp&nbsp <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
?>
 
check out the FAQ written by sleipnir214 on this site
 
I know what that does and I started doing it like that BUT that script generates a new page and I want to display it in the seconds part of my table so the rest of the screen remains the same !!!
 
i'm not following you.

what do you want in the first part of your screen? the form?
you want the results of what displayed in the second half your screen?

 
Yes that's it exactly.....

The scripts shows te result in the second table on the screen
But now I want to able to browse back and forward .
 
the script generates a new page

yes it does. without using ajax that is inevitable.

but, you can always have the form displayed on the same page as the results - no problem there.

and ... your code looks to me as though it does that just fine.

so the area of doubt is in the display_db_query function. can you post this please.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top