Sorry, I should have been more clear:
Thanks. ihave a few questions (couldn\'t make it work):
This goes directly into the page:
****which page? searchform.php or searchform.htm?
Answer:
All of this code can go into the same page (the results page, it would have to be a .php page). The if elseif statements below, the previous and next statements, and the function at the bottom to actually call the SQL.
if(!isset($end))
{
$begin=0;
$end=25;
}
elseif($direction==\"next\")
{
$begin=$begin+25;
$end=25;
}
elseif($direction==\"previous\")
{
$begin=$begin-25;
$end=25;
}
$where.=\" LIMIT $begin,$end\";
TheLIMITSQLStatement ($columns_to_select,$maintable,$where );
****i only have one table and database. how do i assign $columns_to_select? where do i present the script for my data, after this script?
ANSWER:
$columns_to_select should be a variable you set equal to the names of the tables in the DB. In your case, replace $columns_to_select with the name of your table in quotes, and send it to the DB that way. You could replace $maintable with the name of your table also (again, send it through in qoutes). The $where gets built by the code above.
Also, you should learn how to use the relational properties of a DB if you are going to be building a DB driven website. Its pretty cool stuff 🙂.
CODE FOR NEXT AND PREVIOUS LINKS:
<a href=\"page.php?direction=next&<?php echo\"begin=$begin&end=$end\"?>\">
<?php if($begin+25<$count) echo\"Next 20>>\"?>
<a href=\"page.php?direction=previous&<?php echo\"begin=$begin&end=$end\"?>\">
<?php if($begin!=0) echo\"<<Previous 20\"; ?>
****can i use $PHP_SELF here?
ANSWER:
Yup. I recommend it in fact. Just make sure it works on your server correctly
My SQL STATEMENT:
function TheLIMITSQLStatement($columns_to_select,$maintable,$where )
{
<!--snip-->
SELECT $columns_to_select FROM $maintable $where
<!--end snip-->
***** where do i put this code?
}
ANSWER:
This code can either go directly in the results page with the rest of the code above, or be included/required from a file with all of your functions. If you are really new, just put it at the bottom, or top of the page (in <?php ?> tags of course). Also note, the function directly above is not complete.
thanks. im new to php. im trying to learn.
ANSWER:
Me too. I've only been coding in it for about 2 months. You will pick it up quickly, especially if you have some prior coding experience (I have a year of C++). Also, read articles from Webmonkey and places like that. I found the book "MySQL/PHP Database Applications" by Greenspan and Bulger to be a great resource. You can learn PHP and MySQL and it has great examples. Let me know if you need any more help.
Ari