-2

I hope to make very simple image gallery. Where users can upload images to the gallery. But to display this image admin has to accept it. To do that I have image management table. In this table there is a column called status. Default value of each image is '0'. What I want is when I click on that '0' of one image it should change to '1'. At the same time status column of database should change to '1'.

I guess I can do this with JavaScript. However I've no idea how to run the MySQL query with JavaScript.

Can anyone tell me how to do this please?

Dmitry Evseev
  • 11,533
  • 3
  • 34
  • 48
Lanka
  • 29
  • 2
  • 11
  • 2
    Well normally you'd use JavaScript to make an Ajax request to your webserver, and then use whatever language you have on the webserver (PHP, Java, JavaScript, etc. - which do you have?) to do the database update. – nnnnnn Oct 31 '14 at 09:22
  • can you give me a example. – Lanka Oct 31 '14 at 09:23
  • Example of what? What programming languge(s) you have available on the server? – JJJ Oct 31 '14 at 09:24
  • Welcome to the wonderfull world of the unknown. What have you tried so far to get the intended result? If you have no clue where to start, i suggest grabbing a tutorial, such as this one. http://www.keyboardninja.eu/webdevelopment/jquery-ajax-call-tutorial – Dorvalla Oct 31 '14 at 09:25
  • @Juhana php,javascript – Lanka Oct 31 '14 at 09:27
  • You have JavaScript available *on the server*? As in Node.js or equivalent? Anyway, https://www.google.com/search?q=update+database+with+php – JJJ Oct 31 '14 at 09:28
  • Thank you juhana I will try. I'm new for web developing. I think I have to learn more... – Lanka Oct 31 '14 at 09:31
  • 1
    @Dorvalla Thank you very much. Your link help me lot. I'm totally new for web development. So thank you very much – Lanka Oct 31 '14 at 10:00

1 Answers1

-1

You can not do that with javascript. you will have to write code for this in your server side language and then you can call that function using AJAX calls. There are several tutorials available on net for AJAX.

Best would be W3SCHOOL.

Your question like the following one.Read this stackoverflow question

Community
  • 1
  • 1
vedbhawsar
  • 75
  • 8
  • 2
    _"You can not do that with javascript."_ - Sure you can. You can run JS server-side. – nnnnnn Oct 31 '14 at 09:27
  • @Gant - I wasn't talking about web sockets, I meant standard http requests and responses using something like [Node.js](http://nodejs.org/) on the server (you know, as used by small companies like eBay). – nnnnnn Oct 31 '14 at 10:19
  • @nnnnnn I wasn't even responding to you, our comments where submitted in the same 10 or so seconds :) – Aurelia Oct 31 '14 at 13:43