How to use php inside of javascript?

ghadams

I am using javascript to retrieve a bunch of values from the Riot API, however I want to store them in my own database using php. For example, I'm trying to store the gameID and this is what I'm trying right now.

      <?php
        $insrt = "INSERT INTO game (gameId)
        VALUES (".<script>b.gameId</script>.")";
        mysqli_query($dbc, $insrt);
        ?>

I'm pretty sure that I'm not even close to correct but I'm not sure how to do this.

AmmarCSE

You need to take a different approach. You can make an ajax call to a php script to do this for you. But the initiator will be javascript from the client side. Using jQuery(let me know if you can't), you can do

$.ajax({url: "insert_game_id.php", data: {gameId :b.gameId} });

and your php script

<?php
        $gameId = $_POST['gameId'];
        $insrt = "INSERT INTO game (gameId)
        VALUES ($gameId)";
        mysqli_query($dbc, $insrt);
?>

See jQuery Ajax POST example with PHP

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

How to add php content or variable inside javascript alert box?! javascript, php, alertbox

분류에서Dev

Use php namespace inside function

분류에서Dev

How to access attributes of php object inside a array of php objects from javascript

분류에서Dev

WordPress 및 PHP의 JavaScript Inside JavaScript

분류에서Dev

Call Javascript function with parameters inside PHP

분류에서Dev

How to use define in php

분류에서Dev

How to use toast message inside Thread in Android

분류에서Dev

How to use a gulp plugin inside a gulp plugin?

분류에서Dev

optparse main function, how to use the options inside

분류에서Dev

How to use regex inside exec with find?

분류에서Dev

How to use param values inside for loop

분류에서Dev

How to use variables inside back-quotes

분류에서Dev

How to delete an element inside a multidimensional array in PHP?

분류에서Dev

How to replace character inside double quote in javascript?

분류에서Dev

how to define a Function inside a Function in javascript?

분류에서Dev

How to call the Javascript file inside Body tag

분류에서Dev

Google Maps - Finding all the markers inside a given radius Javascript/Php

분류에서Dev

javascript call inside php where loop not working and breaks query

분류에서Dev

Can't use my php variable in JavaScript

분류에서Dev

how to use the output value in php

분류에서Dev

How to use javascript to preload images

분류에서Dev

How to properly use javascript with SUBMIT?

분류에서Dev

How to use javascript with selenium python

분류에서Dev

How to use a virtual keyboard inside Libre Office Writier?

분류에서Dev

How do I use an array variable inside an array of structures?

분류에서Dev

How to use computed method inside foreach in knockout.js

분류에서Dev

How do I use service methods inside an @Secured expression?

분류에서Dev

How do I use a @Html.ActionLink inside a for loop

분류에서Dev

How to use Dropdown list inside kendo grid mvvm

Related 관련 기사

  1. 1

    How to add php content or variable inside javascript alert box?! javascript, php, alertbox

  2. 2

    Use php namespace inside function

  3. 3

    How to access attributes of php object inside a array of php objects from javascript

  4. 4

    WordPress 및 PHP의 JavaScript Inside JavaScript

  5. 5

    Call Javascript function with parameters inside PHP

  6. 6

    How to use define in php

  7. 7

    How to use toast message inside Thread in Android

  8. 8

    How to use a gulp plugin inside a gulp plugin?

  9. 9

    optparse main function, how to use the options inside

  10. 10

    How to use regex inside exec with find?

  11. 11

    How to use param values inside for loop

  12. 12

    How to use variables inside back-quotes

  13. 13

    How to delete an element inside a multidimensional array in PHP?

  14. 14

    How to replace character inside double quote in javascript?

  15. 15

    how to define a Function inside a Function in javascript?

  16. 16

    How to call the Javascript file inside Body tag

  17. 17

    Google Maps - Finding all the markers inside a given radius Javascript/Php

  18. 18

    javascript call inside php where loop not working and breaks query

  19. 19

    Can't use my php variable in JavaScript

  20. 20

    how to use the output value in php

  21. 21

    How to use javascript to preload images

  22. 22

    How to properly use javascript with SUBMIT?

  23. 23

    How to use javascript with selenium python

  24. 24

    How to use a virtual keyboard inside Libre Office Writier?

  25. 25

    How do I use an array variable inside an array of structures?

  26. 26

    How to use computed method inside foreach in knockout.js

  27. 27

    How do I use service methods inside an @Secured expression?

  28. 28

    How do I use a @Html.ActionLink inside a for loop

  29. 29

    How to use Dropdown list inside kendo grid mvvm

뜨겁다태그

보관