Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8860097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:12:09+00:00 2026-06-14T15:12:09+00:00

I look up the image associated with a pokemon and display it with php.

  • 0

I look up the image associated with a pokemon and display it with php. Then I want to be able to “flip the card over,” by clicking on it. I’ve got the first click down, but the second click to flip the card back over isn’t working. I figure it’s the syntax of my php variable within the JS:

<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">

<title>
'Murica!
</title>

<script>

function changeImage()
{

element=document.getElementById('pokemon_card')

if 
(element.src.match("http://dmisasi.files.wordpress.com/2010/12/david-pokemon-card-     back.jpg?w=750"))
{element.src="'.$result['image_url'].'";} //<- no idea how to express the php string variable here

else
{element.src="http://dmisasi.files.wordpress.com/2010/12/david-pokemon-card-back.jpg?     w=750";}

}

</script>

</head>

<body>

<?php

$dbhost = 'databasePlace';
    $dbname = 'mine';
    $dbuser = 'me';
    $dbpass = '******';

    $link = mysqli_connect($dbhost,$dbuser,$dbpass,$dbname);

    mysqli_select_db($link,$dbname);    


$name = $_GET["fname"];



                $query = sprintf("SELECT image_url, Type
                                  FROM Pokemon c
                                  WHERE c.name='%s'",
                mysqli_real_escape_string($link,$name));

    $result = mysqli_fetch_assoc(mysqli_query($link,$query));

    echo '<img id="pokemon_card" onclick="changeImage()" height="225" 
width="165" src="'.$result['image_url'].'"/>';

mysqli_close($link);

?>

</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T15:12:10+00:00Added an answer on June 14, 2026 at 3:12 pm

    The easiest way would be to put a little PHP script inside the Javascript, like this…

    <script type="text/javascript">
    function bla() {
        var thevar = "<?php echo $thevar; ?>";
    }
    </script>
    

    In other words, according to your question, you would replace the line {element.src="'.$result['image_url'].'";} with the line {element.src="<?php echo $result['image_url']; ?>";}

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please look at this image here is 3 tables , and out i want
I have a UIProgressView which I want to look like this image. I have
Please check out this image: Look at the part that says 'keyboard' I want
I am able to successfully look up an image from the ALAssetsLibrary and use
I want users to be able to upload an image and have it be
I have a image who's width and height i got in Javascript. i want
Take a look at the image below. I defined the red boxes inside the
Imagine I am plotting e.g. this: plot(1:1500,1:1500) This will look like the image below,
sometimes i see an image not being served when the browser look at www.somesite.com/some_image.jpg
I have this image: In this image I have 11 shapes (look like ellipses).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.