create forward buttons - html - php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Fegero
Forum Newbie
Posts: 7
Joined: Sat Jul 20, 2002 6:10 pm

create forward buttons - html - php

Post by Fegero »

Yes I am new to PHP so here is my problem.

I am trying to create navigation buttons to move thru my web site. I have a mysql database with a table filled with names and pages.

I have a file called "MYFUNCTIONS.php" Here I have a function for turning on and off the database, and a function which will show you all the items which are passed into the file. Lets give the function the name "pictures."

DATABASE
name page
bob 2
sam 2
mike 3
sue 3

If iI create a index.php and call the function pictures(2)
I have the function created to show me all the names related to page 2
If I change the code and say pictures(3) then all the names on three will show.

THE QUESTION!!!!! How could I get the page to be seen user friendly. In other words I know how to create <- and -> arrows to move to new pages in html, but in PHP what do I need to do in my index.php to have a user control the function and send it as pictures($page) or something like that... all dependent on if they click the forward or back buttons on my site?

I hope you understand my question. Thanks in advanced for any help I receive.
I can also be reached at feger585@yahoo.com

Fegero
Fegero
Forum Newbie
Posts: 7
Joined: Sat Jul 20, 2002 6:10 pm

I'll make this simple

Post by Fegero »

How can I make a user change the variable in the index file to be passed off the the Function scripts.

INDEX.php MyFunctions($bob);


FUNCTIONS.INC - search the database for $bob


I only need to make the user change $bob

Yes, I'am getting $#@$@# (upset) with my knowledge limitations in PHP.


Thanks again.
fatalcure
Forum Contributor
Posts: 141
Joined: Thu Jul 04, 2002 12:57 pm
Contact:

Post by fatalcure »

you need to go get some basic tutorials on php and how to pass variables from one page to the next. Give it a try and then come back if you have any problems.
Fegero
Forum Newbie
Posts: 7
Joined: Sat Jul 20, 2002 6:10 pm

I guess I did not explain well

Post by Fegero »

Passing the variables between pages is not the problem. I have that down fine. What I am trying to do right now is knowing how to have the end user manipulate the variable in HTTP/PHP. using an icon.

Again what I am trying to do is have the FILE.php be the page the user sees. On that page the default would be page 2. That person now has the option to pick the Right Icon to go to page 3 or the LEFT icon to go to page 1. Once chosen, the function would be called to change the data.

Now my question would be... What do I need to do to be able to create a icon inorder for the user to change pages? If they click on the RIGHT button then I would want to

$current_page +1;
myfunction($current_page)

So how do I make a button to control the variable before its passed to the function?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Basically you don't create a button to control the variable and the end user doesn't manipulate it either. PHP is server-side which means that the server does all the work and all the client's browser sees is HTML (and Javascript if you've got it) code. You don't use links to call functions - you can't PHP is not like Javascript which is client-side and therefore run by the browser.

The easiest thing you can do is pass the page number in the URL as a query string. For example you could have URL's which look like this:

Code: Select all

http://www.yoursite.com/articles/something.php?pageno=2
Then using the value for page number set in the URL you can do something like the following:

Code: Select all

if (isset($_GET&#1111;'pageno']) &#123;
    $page_number = $_GET&#1111;'pageno'];
&#125; else &#123;
    $page_number = 1;
&#125;
$page_number_next = $page_number + 1;
$page_number_prev = $page_number - 1;
Then you can add this information to the next and previous buttons as well as to whatever code that includes the actual page content. So your previous button would look something like:

Code: Select all

echo '<a href="something.php?pageno='.$page_number_prev.'"><img src="prevbutton.gif" width="x" height="y" alt="Previous Page ('.$page_number_prev.')" /></a>';
and you'd have something almost identical (previous replaced with next) for the next button.

Mac
Fegero
Forum Newbie
Posts: 7
Joined: Sat Jul 20, 2002 6:10 pm

Thanks, it sounds good

Post by Fegero »

For some reason that is what I thought I would be doing. Thanks for the info. I'll give this a try for a while and see what happens.

Thanks again


Fegero
Post Reply