Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
334 views
in Technique[技术] by (71.8m points)

javascript - Call PHP file without using form action

I am new to php. I did a little search but did not find a good solution. So posting the question here.

I have several thumbnail images in my webpage. Something like:

 <img src="" id="thumb1">
 <img src="" id="thumb2">
 <img src="" id="thumb3">
 <img src="" id="thumb4">

I want to call load a php file when a user clicks on any of these thumbnail images and pass the id of the image to the php file. This php file queries the database with the image id and displays the relevant information. So far I used "form action" to call a php file.

Can you please tell me how to call php file and pass the image id?

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use links:

<a href="php_file.php?id=thumb1"><img src="" id="thumb1"></a>
<a href="php_file.php?id=thumb2"><img src="" id="thumb2">/a>
<a href="php_file.php?id=thumb3"><img src="" id="thumb3">/a>
<a href="php_file.php?id=thumb4"><img src="" id="thumb4">/a>

php side: $_GET['id'];


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...