Click here to Skip to main content
15,880,392 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
Questionsimplexml_load_string returning empty structure, no errors. why? Pin
GregStevens29-Jun-11 4:30
GregStevens29-Jun-11 4:30 
AnswerRe: simplexml_load_string returning empty structure, no errors. why? PinPopular
GregStevens30-Jun-11 11:35
GregStevens30-Jun-11 11:35 
GeneralRe: simplexml_load_string returning empty structure, no errors. why? Pin
Peter_in_278030-Jun-11 14:51
professionalPeter_in_278030-Jun-11 14:51 
GeneralRe: simplexml_load_string returning empty structure, no errors. why? Pin
GregStevens6-Jul-11 15:18
GregStevens6-Jul-11 15:18 
QuestionGet & show data using CURL Pin
ahmed0181126-Jun-11 18:33
ahmed0181126-Jun-11 18:33 
QuestionHow to include a Javascript variable inside a php function? Pin
Glen Villar24-Jun-11 12:58
Glen Villar24-Jun-11 12:58 
AnswerRe: How to include a Javascript variable inside a php function? Pin
Graham Breach25-Jun-11 2:52
Graham Breach25-Jun-11 2:52 
AnswerRe: How to include a Javascript variable inside a php function? Pin
GregStevens6-Jul-11 15:29
GregStevens6-Jul-11 15:29 
You have to think about it this way:

PHP code works with what the server "knows".
Javascript code works with what the browser / client "knows".

To get them to interact, you need to explicitly "pass" information back and forth between the two.

For example, if you have a variable in the javascript, you can "pass" the value to the server by passing it with a GET variable, e.g.

<script language="javascript">
Fuction PassNumber(nVal) {
   location.href = 'mypage.php?n='+nVal;
}
</script>


Then, on the server side, you receive the GET variable to produce the effect that you want:

<?php

$nval = $_GET['n'];
if ($nval)
{
  print('<script>alert('.$nval.');</script>');
}
?>


Contrariwise, when you have the PHP variable on the server side, you can use that to feed it to the Javascript function when rendering your onclick function:

<input type="text" name="text1" value="200" /><br />
<input type="button" value="Go" onClick="PassNumber(this.text1.value+<?php print($nval) ?>)"   />


This requires a re-load of the page, and change of URL, each time you click the button. To do it more "subtley", without a reload, you would have to use AJAX: but the principle would be the same. Pass the information between Server and Browser using calls to the PHP page with GET.
--Greg

QuestionPHP with Drupal Pin
CodingLover23-Jun-11 19:17
CodingLover23-Jun-11 19:17 
AnswerRe: PHP with Drupal Pin
Peter_in_278023-Jun-11 19:26
professionalPeter_in_278023-Jun-11 19:26 
GeneralRe: PHP with Drupal Pin
CodingLover23-Jun-11 19:41
CodingLover23-Jun-11 19:41 
AnswerRe: PHP with Drupal Pin
CodingLover24-Jun-11 16:01
CodingLover24-Jun-11 16:01 
QuestionPython Threading.Timer Executes Immediately Pin
icemclean21-Jun-11 10:07
icemclean21-Jun-11 10:07 
AnswerRe: Python Threading.Timer Executes Immediately Pin
etkid8425-Aug-11 3:39
etkid8425-Aug-11 3:39 
QuestionI want to learn whow to make like that project. Pin
rabbyweb16-Jun-11 12:50
rabbyweb16-Jun-11 12:50 
AnswerRe: I want to learn whow to make like that project. Pin
walterhevedeich16-Jun-11 15:38
professionalwalterhevedeich16-Jun-11 15:38 
Questionsimulated annealing for distribution in php Pin
wahyu oke14-Jun-11 9:58
wahyu oke14-Jun-11 9:58 
QuestionI urgently need an online exam or test script Pin
E.O.Akinyemi13-Jun-11 13:53
E.O.Akinyemi13-Jun-11 13:53 
AnswerRe: I urgently need an online exam or test script Pin
walterhevedeich16-Jun-11 15:35
professionalwalterhevedeich16-Jun-11 15:35 
AnswerRe: I urgently need an online exam or test script Pin
Glen Villar16-Jun-11 18:32
Glen Villar16-Jun-11 18:32 
AnswerRe: I urgently need an online exam or test script Pin
cjoki17-Jun-11 11:04
cjoki17-Jun-11 11:04 
AnswerRe: I urgently need an online exam or test script Pin
thatraja8-Jul-11 17:05
professionalthatraja8-Jul-11 17:05 
QuestionBreak down URL Pin
djhankypark11-Jun-11 2:46
djhankypark11-Jun-11 2:46 
AnswerRe: Break down URL Pin
Graham Breach11-Jun-11 5:37
Graham Breach11-Jun-11 5:37 
GeneralRe: Break down URL Pin
djhankypark11-Jun-11 6:42
djhankypark11-Jun-11 6:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.