Total Zero
Posts: 5
34 credits Members referred : 0
« on: Apr 16, 2007, 04:10:58 pm »
Hello Olaf,
I think this script can help me if I can set it up right.
I have a similar problem to some other person, but they managed to resolve it... but didn't say how, pixeltrace I think it was!
I suppose I need to learn about directory structure...
I get the follwing error in example.php
Warning: main(/diska/www/htdocs/classes/my_pagina/my_pagina_class.php) [function.main]: failed to open stream: No such file or directory in /disks/diskh/zco/xxxxx/public_html/FYPSite/classes/my_pagina_class/example.php on line 2
Warning: main() [function.include]: Failed opening '/diska/www/htdocs/classes/my_pagina/my_pagina_class.php' for inclusion (include_path='.:/usr/share/pear') in /disks/diskh/zco/xxxxx/public_html/Site/classes/my_pagina_class/example.php on line 2
Fatal error: Class 'MyPagina' not found in /disks/diskh/zco/xxxxx/public_html/Site/classes/my_pagina_class/example.php on line 4
so it has something to do with this line i presume...
all errors are gone if you're using the right pathes.
Total Zero
Posts: 5
34 credits Members referred : 0
« Reply #4 on: Apr 16, 2007, 05:20:49 pm »
No errors come up with the modification, records display...but this part does'nt look right...
it echos like this example .php
rec. to of 5
shouldn't it be...
rec. 1 to 1 of 5
since i set the max number of records per page to 1 in db_config.php?
Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6691
34714 credits Members referred : 374
It's time to use PHP5!
« Reply #5 on: Apr 17, 2007, 09:03:39 am »
don't have this problem, your using these settings? (and of course the unchanged example.php file)
Code:
// some external constants to controle the output define("QS_VAR", "page"); // the variable name inside the query string (don't use this name inside other links) define("NUM_ROWS", 5); // the number of records on each page
define("STR_FWD", ">>"); // the string is used for a link (step forward) define("STR_BWD", "<<"); // the string is used for a link (step backward)
// use the rught pathes to get it working with the php function getimagesize define("IMG_FWD", "./forward.gif"); // the image for forward link define("IMG_BWD", "./backward.gif"); // the image for backward link
define("NUM_LINKS", 1); // the number of links inside the navigation (the default value)
Total Zero
Posts: 5
34 credits Members referred : 0
« Reply #6 on: Apr 17, 2007, 12:45:56 pm »
MY example looks like this:
Code:
<?php include("my_pagina_class.php");
$test = new MyPagina;
$test->sql = "SELECT * FROM vacancies ORDER BY id"; // the (basic) sql statement (use the SQL whatever you like) $result = $test->get_page_result(); // result set $num_rows = $test->get_page_num_rows(); // number of records in result set $nav_links = $test->navigation(" | ", "currentStyle"); // the navigation links (define a CSS class selector for the current link) $nav_info = $test->page_info("to"); // information about the number of records on page ("to" is the text between the number) $simple_nav_links = $test->back_forward_link(true); // the navigation with only the back and forward links, use true to use images $total_recs = $test->get_total_rows(); // the total number of records ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>MyPagina example page</title> <style type="text/css"> <!-- body { font-family:"Courier New", Courier, mono; } .currentStyle { font-size:1.5em; font-weight:bold; } --> </style> </head>
<body> <h2>Example page for MyPagina class</h2> <p>The page navigation (pagination) of lists with records from a (MySQL) database is often used on a lot of dynamic websites. This class is extremely easy to use in your existing application: just use your own SQL statement and voila you get information like the result set (you need this for later output, page navigation links and the (current) number of records. While using this class all other query string parts are included inside the page links. An example database table (with data) is included.</p> <p>This information shows the current range of records and the total number of records.</p> <p><b><?php echo "rec. ".$nav_info." of ".$total_recs; ?></b></p> <p> </p> <p>Here the records (id and type):</p> <p> <?php for ($i = 0; $i < $num_rows; $i++) { $type = mysql_result($result, $i, "type"); $id = mysql_result($result, $i, "id"); echo ($id <= 9) ? " ".$id : $id; echo " -> ".$type."<br>\n"; } ?> <?php echo "<hr>\n"; echo "<p>The navigation() method is showing this kind of links:</p>"; echo "<p>".$nav_links."</p>"; echo "<p>Notice the large number of the current link, you can modify the style with CSS.</p>"; echo "<hr>\n";
echo "<p>The back_forward_link() method, shows only for- and backward links (you can use it for small recordsets):<br> (this example is using images)</p>"; echo "<p>".$simple_nav_links."</p>"; ?> </p> <p> </p> </body> </html> <?php $test->free_page_result(); // if your result set is large then free the result here ?> <?php
echo ($id <= 9) ? " ".$id : $id; I don't really understand this line, it just limits the id to 9 no?
My db_config looks like this
Code:
// some external constants to controle the output define("QS_VAR", "page"); // the variable name inside the query string (don't use this name inside other links) define("NUM_ROWS", 1); // the number of records on each page
define("STR_FWD", ">>"); // the string is used for a link (step forward) define("STR_BWD", "<<"); // the string is used for a link (step backward)
// use the rught pathes to get it working with the php function getimagesize define("IMG_FWD", "./forward.gif"); // the image for forward link define("IMG_BWD", "./backward.gif"); // the image for backward link
define("NUM_LINKS", 5); // the number of links inside the navigation (the default value) ?>
so I'm not sure what the problem is because total number of records echos ok, but .$nav_info. does not.
« Last Edit: Apr 17, 2007, 12:49:59 pm by stressed »
Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6691
34714 credits Members referred : 374
It's time to use PHP5!
« Reply #7 on: Apr 17, 2007, 02:59:06 pm »
the "9" has only an extra space to line up,
first try the examples as provided...
Total Zero
Posts: 5
34 credits Members referred : 0
« Reply #8 on: Apr 17, 2007, 05:31:41 pm »
ok I will try the example first.
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=6395