Page 1 of 1

Calling a function in php

Posted: Sun Aug 31, 2003 6:29 pm
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

Posted: Sun Aug 31, 2003 6:32 pm
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

Posted: Sun Aug 31, 2003 6:37 pm
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?

Posted: Sun Aug 31, 2003 6:46 pm
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.

Posted: Sun Aug 31, 2003 6:50 pm
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?

Posted: Sun Aug 31, 2003 7:29 pm
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?

Posted: Sun Aug 31, 2003 8:23 pm
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.