Author Topic: image_hot button on the details page  (Read 7272 times)

0 Members and 1 Guest are viewing this topic.

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
image_hot button on the details page
« on: November 30, 2008, 01:27:54 PM »
Hi,

I have already this field on my database: image_hot. I added it with this code: (ALTER TABLE 4images_images ADD image_hot TINYINT(1) DEFAULT '0' NOT NULL).

I want to have a button on my details page, so when the user like a picture, he can click on this button.

All what I want is when the user click on the button, the field image_hot will get a 1 (Instead of 0).

I know it is easy to code it, but I couldn't. :oops:

Any help is appreciated.

Many thanks in advance,

Offline KurtW

  • 4images Guru
  • *******
  • Posts: 2.778
    • View Profile
    • Malediven-Bilder ~~Dreams~~
Re: image_hot button on the details page
« Reply #1 on: November 30, 2008, 03:17:29 PM »
Hi,
and what do you do with the rate form?

Kurt

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: image_hot button on the details page
« Reply #2 on: November 30, 2008, 03:27:55 PM »
Thank you KurtW for your reply.

Actually I want to have a page on my site with only HOT/HONNORED/or something else . It has nothing to do with the rate system of 4images.

I already added the botton to my details page and I can create the HOT/HONNORED/or something page. All what I need is to add 1 to the field image_hot in 4images DB when the user click on the botton.

I hope you can code it for me. I will appreciate your help.

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: image_hot button on the details page
« Reply #3 on: November 30, 2008, 06:59:05 PM »
Any help please. I tried everything, but without any success.

I really need this code.

Many thanks in advance,

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: image_hot button on the details page
« Reply #4 on: November 30, 2008, 07:43:49 PM »
In details.php find
Code: [Select]
//-----------------------------------------------------
//--- Save Comment ------------------------------------
//-----------------------------------------------------

Insert above:
Code: [Select]
if ($action == "image_hot" && isset($HTTP_POST_VARS[URL_ID]))
{
  $sql = "UPDATE ".IMAGES_TABLE." SET image_hot = 1 WHERE image_id = ".(intval($HTTP_POST_VARS[URL_ID]) ? intval($HTTP_POST_VARS[URL_ID]) : 0);
  if ($site_db->query($sql))
  {
    $msg .= (($msg != "") ? "<br />" : "")."Image set to hot";
  }
  else
  {
    $msg .= (($msg != "") ? "<br />" : "")."error";
  }
 
}

In details.html template add:
Code: [Select]
<form name="image_hot" action="{self}" method="post">
  <input type="hidden" name="action" value="image_hot" />
  <input type="hidden" name="id" value="{image_id}" />
  <input type="submit" name="image_hot" value="{lang_image_hot}" class="button" />
</form>
« Last Edit: November 30, 2008, 08:09:06 PM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: image_hot button on the details page
« Reply #5 on: November 30, 2008, 08:03:23 PM »
Thanks V@no :D

I got this error:

Quote
Parse error: syntax error, unexpected ')' in /hsphere/local/home/site/mysite.com/details.php on line 297

Do you know why?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: image_hot button on the details page
« Reply #6 on: November 30, 2008, 08:09:29 PM »
try again code in details.php
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: image_hot button on the details page
« Reply #7 on: November 30, 2008, 08:33:33 PM »
It works V@no :D. Thank you very much.

I hope I am not asking you too much, but maby someone else can help.

------------------------------------------------------------------------------------------------------------------------------------------------------
Before the database will be apdated, I want to ask the user if he/she sure about his action. Something like:

Are you sure....? Yes or not

Yes = update the database
No = Return to the details page.

Any help is appreciated


Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: image_hot button on the details page
« Reply #8 on: November 30, 2008, 08:58:51 PM »
Not exactly what you asked, but close and most simplest way:
(replace first line in code for template)
Code: [Select]
<form name="image_hot" action="{self}" method="post" onSubmit="return confirm('Are you sure?');">
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: image_hot button on the details page
« Reply #9 on: November 30, 2008, 09:11:03 PM »
Almost what I want. Thank you very very much.
You saved my day :)

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: image_hot button on the details page
« Reply #10 on: December 24, 2008, 03:20:18 AM »
Hi,

I have a question,

I want to use een input text to save infor in the database instead of updating the table.

I already have the input text on the details page and I use this code who does not work properly on the details.php:

Code: [Select]
if ($action == "youtube_link" && isset($HTTP_POST_VARS[URL_ID]))
{
  $sql = "INSERT INTO ".IMAGES_TABLE."
 
 
  (image_youtube_link)
              VALUES
              ('$youtube_link')";
 
  if ($site_db->query($sql))
  {
    $msg .= (($msg != "") ? "<br />" : "")."YouTube link is toegestuurd";
  }
  else
  {
    $msg .= (($msg != "") ? "<br />" : "")."error";


My Idea is the giving the users the chance to submit a link from the details page.


Thanks in advance for correcting my code.