Calling a function in 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
Nicholasp27
Forum Newbie
Posts: 4
Joined: Sun Aug 31, 2003 6:29 pm

Calling a function in php

Post by Nicholasp27 »

I have a function I made called updateAvailability()
in this same php file, it shows the user "yes" if something is available and "no" if something isn't

i want them to be able to click the yes or no and have it call updateAvailability()

how do i do this?
i tried onClick, but it didn't work

the file is edit_my_properties.php
the function is called updateAvailability()

thanks
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

php is executed server-side, onClick is a client-side event-handler.
Between two requests there is no connection server<->client.
Have a read of viewtopic.php?t=1030
Nicholasp27
Forum Newbie
Posts: 4
Joined: Sun Aug 31, 2003 6:29 pm

Post by Nicholasp27 »

i'd love nothing more than for it to go ahead and reload the page for me

basically, i just want the click to run a simple update query to the mysql db and then reload the page

how do i do this in php?
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Nicholasp27 wrote: basically, i just want the click to run a simple update query to the mysql db and then reload the page

how do i do this in php?
How do you get the info of the articles in the first place? If you load a page (say items.php) that shows you the status of items, a link

Code: Select all

<a href="items.php">Reload</a>
...would produce the same results, as your updateAvailability() is bundled in there. But please correct me if I'm wrong.
Nicholasp27
Forum Newbie
Posts: 4
Joined: Sun Aug 31, 2003 6:29 pm

Post by Nicholasp27 »

i do a select query to get the value in the field "active"
it scrolls through every item to get their value and display them in a table
i want the user to be able to click the value (yes or no) and then it will run an update query to change it to the other value

i would like to have it run the query and refresh the same page

if i have to, i can have the link go to a new page, passing the item ID, and the new page can run the query for that item ID, but I'd rather not

in either case, how could i do this?
Nicholasp27
Forum Newbie
Posts: 4
Joined: Sun Aug 31, 2003 6:29 pm

Post by Nicholasp27 »

ok, i'm just calling a new page, make_available.php

that page just has an sql statement

sql=UPDATE tblName SET active=yes WHERE ID=$listingID;

but i can't pass a "$listingID" only "listingID"

but then the sql query won't work

what am i doing wrong?
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Perhaps you should read up on Passing Variables (last link in my signature).

Likely, you need to use $_GET['listingID'] instead of just $listingID.
Post Reply