javascript - Running php from user onclick -


I'm not sure how I can explain it, but here's a website for my attraction. That's a historic village among my categories. When the user opens the pages of the historic villages, then they get a list of the villages displayed from the database. The way I display them: a picture of attraction by name. What do I want that the user is unable to click villages (by creating a clickable link to name and photo) and redirect the user to a page which will run a PHP script which will display more information than the database selected village In this way I will have only one page for all the attractions, which will display the individual notifications to the user every time, all the pages will be in the link Instead of Hnt.

This is my code which displays the fragments of the villages:

  $ sql = "select name", `location`,` description`, `air Haunch `,` imlink`, `pagilink`" "` from charm '' 'WHERE` category` =' histavi '' '; $ Result = mysql_query ($ sql, $ link); If (!! $ Result) {echo "DB error, could not query database \ n"; Echo 'mysql error:'. Mysql_error (); Go out; } While ($ line = mysql_fetch_assoc ($ result)) {echo $ line ['name']; Echo "& lt; img src = '" $ line [' Iglink '] "' & gt;"; }   

Do any of you have any suggestions on how to create this output link and run it to show users the selection of PHP?

  while ($ line = mysql_fetch_assoc ($ result))  

* For example, in the $ line ['pagelink'], pagelink should be included in the form below as /viewVillage.php?village_id=1/viewVillage.php?village_id=2 and so on. * / Echo "& lt; a href = '" $ line [' paglink '] "' & gt;" . $ Line ['name'] "& Lt; img src = '" $ line [' Iglink ']' '' & gt; & lt; / a & gt; "; }

This will generate a list of villages like yours,

  & lt; A href = "/ viewvillage.php? Village_id = 1" & gt; Village Name 1 Village Image 1 & lt; / A & gt; & Lt; a href = "/ view description php? village_id = 2" & gt; Village Name 2 Village Image 2 & lt; / A & gt; & Lt; A href = "/ view description php? Village_addly = 3" & gt; Village Name 3 Village Image 3 & lt; / A & gt; .....   

When you click any link, it will be redirected to the viewVillage.php page. Now you get special village using $ _GET ['village_id']

viewVillage.php

  (Isset ($ _GET ['village_id']]) and $ _SERVER ['REQUEST_METHOD'] == 'GET') {$ village = $ _GET ['village_id']; // then do your stuff here}    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -