Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

PHP or Javascript for this?

 
   Database Forums (Home) -> PHP RSS
Next:  Incremental Cube update consuming more tempdb spa..  
Author Message
Akhenaten

External


Since: May 16, 2007
Posts: 2



(Msg. 1) Posted: Sun May 20, 2007 12:50 pm
Post subject: PHP or Javascript for this?
Archived from groups: comp>lang>php (more info?)

I'm wanting to create an hyperlink that will execute a mysql_query and
then refresh the current page if it's clicked on. I've similar things
created via javascript but didn't know if such was possible with PHP.

 >> Stay informed about: PHP or Javascript for this? 
Back to top
Login to vote
Akhenaten

External


Since: May 16, 2007
Posts: 2



(Msg. 2) Posted: Sun May 20, 2007 1:54 pm
Post subject: Re: PHP or Javascript for this? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On May 20, 3:23 pm, Philipp Grassl wrote:
> You could do it like
>
> ---
> <?
>
> if (isset($_GET['q']) && $_GET['q']=='y')
> {
> mysql_query(...);
> header("Location: ?");
>
> }
>
> echo "<a href='?q=y'>Execute Query</a>";
>
> ?>
> ---
>
> However, using this technique all the GET-variables would be cleared.
> Also, I personally would use two PHP-Files, if you don't need to use the
> returned data from the query in the first script:


The problem is I do need the return data. I guess a good example would
be something similar to a voting poll. If you haven't voted then the
"vote" img will be displayed. Clicking on it will execute a mysql
update. The page will then refresh with the vote results in place of
the vote image.

 >> Stay informed about: PHP or Javascript for this? 
Back to top
Login to vote
Philipp Grassl

External


Since: May 20, 2007
Posts: 1



(Msg. 3) Posted: Sun May 20, 2007 4:56 pm
Post subject: Re: PHP or Javascript for this? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

You could do it like

---
<?

if (isset($_GET['q']) && $_GET['q']=='y')
{
mysql_query(...);
header("Location: ?");
}

echo "<a href='?q=y'>Execute Query</a>";

?>
---

However, using this technique all the GET-variables would be cleared.
Also, I personally would use two PHP-Files, if you don't need to use the
returned data from the query in the first script:

--- file1.php
<?

echo "<a href='query.php'>Execute Query</a>";

?>
--- file2.php
<?

mysql_query(...);
[Do sth.]
header("Location: file1.php");

?>
---

Akhenaten schrieb:
> I'm wanting to create an hyperlink that will execute a mysql_query and
> then refresh the current page if it's clicked on. I've similar things
> created via javascript but didn't know if such was possible with PHP.
>
 >> Stay informed about: PHP or Javascript for this? 
Back to top
Login to vote
Jerry Stuckle

External


Since: Aug 11, 2004
Posts: 1367



(Msg. 4) Posted: Sun May 20, 2007 9:35 pm
Post subject: Re: PHP or Javascript for this? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Akhenaten wrote:
> On May 20, 3:23 pm, Philipp Grassl wrote:
>> You could do it like
>>
>> ---
>> <?
>>
>> if (isset($_GET['q']) && $_GET['q']=='y')
>> {
>> mysql_query(...);
>> header("Location: ?");
>>
>> }
>>
>> echo "<a href='?q=y'>Execute Query</a>";
>>
>> ?>
>> ---
>>
>> However, using this technique all the GET-variables would be cleared.
>> Also, I personally would use two PHP-Files, if you don't need to use the
>> returned data from the query in the first script:
>
>
> The problem is I do need the return data. I guess a good example would
> be something similar to a voting poll. If you haven't voted then the
> "vote" img will be displayed. Clicking on it will execute a mysql
> update. The page will then refresh with the vote results in place of
> the vote image.
>

There are several ways you can do it. For instance, you can store the
$_GET variables in $_SESSION. You can add the variables when building
your "vote" link. You can put them as hidden fields in a form that is
submitted when they click on the link...

All kinds of things you can do. Which way is best is for you to decide.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex RemoveThis @attglobal.net
==================
 >> Stay informed about: PHP or Javascript for this? 
Back to top
Login to vote
Ravi

External


Since: May 10, 2007
Posts: 5



(Msg. 5) Posted: Mon May 21, 2007 6:14 am
Post subject: Re: PHP or Javascript for this? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On May 21, 12:50 am, Akhenaten wrote:
> I'm wanting to create an hyperlink that will execute a mysql_query and
> then refresh the current page if it's clicked on. I've similar things
> created via javascript but didn't know if such was possible with PHP.

These all are long methods take a function for displaying image and
for sucessfull message

like:

if (isset($_GET['q']) && $_GET['q']=='y')
{
mysql_query(...);
display("message");
}
else
display();

function display($msg){
if(is_empty($msg){
then logic for displaying image
}else{
logic for displaying the sucessfull message.
}
}

make sure all the variables in the function should be global variables.
 >> Stay informed about: PHP or Javascript for this? 
Back to top
Login to vote
Jerry Stuckle

External


Since: Aug 11, 2004
Posts: 1367



(Msg. 6) Posted: Mon May 21, 2007 9:48 am
Post subject: Re: PHP or Javascript for this? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Ravi wrote:
> On May 21, 12:50 am, Akhenaten wrote:
>> I'm wanting to create an hyperlink that will execute a mysql_query and
>> then refresh the current page if it's clicked on. I've similar things
>> created via javascript but didn't know if such was possible with PHP.
>
> These all are long methods take a function for displaying image and
> for sucessfull message
>
> like:
>
> if (isset($_GET['q']) && $_GET['q']=='y')
> {
> mysql_query(...);
> display("message");
> }
> else
> display();
>
> function display($msg){
> if(is_empty($msg){
> then logic for displaying image
> }else{
> logic for displaying the sucessfull message.
> }
> }
>
> make sure all the variables in the function should be global variables.
>

You should not use global variables. If you need a variable in a
function, you should pass it as a parameter.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex.DeleteThis@attglobal.net
==================
 >> Stay informed about: PHP or Javascript for this? 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
JavaScript to PHP? - I was just wondering that if it is possible to do almost anything you can do in JavaScript in PHP.

Javascript - I have a calendar formed with javascript. This line <script>this.form.orderdatefrom_Year_ID.value</script> returns the year-textbox.But in Javascript. How can I pass the javascript variable to php so to further use it?

php in javascript - I have create a checkbox,call getS function in onclick event. I append value of variable output with value $text. It works well but when I changed value of $text to a paragraph of text, it will occur error on the page. Please advise. Thanks. <script....

php within javascript - For a photo display I am using a javascript I found on the net (freeware). The Java script code has to be placed within head and /head tags The Java code consists of the start <script language="JavaScript1.2"> Then about 150 lines of ...

php using javascript objects - I want to initialize a TEXTAREA with text depending on the values already selected in other areas - input type=TEXT or SELECT. How can I set a PHP variable with a value retrieving those HTML object values ?
   Database Forums (Home) -> PHP All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]