TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 790
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 640
  • Total: 641
  • tino

Mood Changer

Started by Lord Anubis, May 31, 2008, 08:49:30 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Lord Anubis

This code is for use the MOOD BOBELS V2.0 mod for SMF


global $db_prefix, $ID_MEMBER, $txt, $context;

$query = db_query(
    "SELECT value
     FROM {$db_prefix}themes
     WHERE ID_MEMBER = $ID_MEMBER
       AND variable LIKE 'bobel'", __FILE__, __LINE__);

if(db_affected_rows() != 0) {
  $row = mysql_fetch_assoc($query);
  $bobel_select = $row['value'];
}
else {
  $bobel_select = '';
}
//Has one been selected?
if(isset($_POST['bobel'])) {
  $bobel_new = $_POST['bobel'];
// There's already a mood selected
  if ($bobel_select <> '') {
    $query = db_query(
      "UPDATE {$db_prefix}themes
       SET value=$bobel_new
       WHERE ID_MEMBER = $ID_MEMBER
         AND variable LIKE 'bobel'
       LIMIT 1", __FILE__, __LINE__);
  }

// No mood previously selected
  else {
    $query = db_query(
      "INSERT INTO {$db_prefix}themes (ID_MEMBER, ID_THEME, variable, value)
       VALUES ($ID_MEMBER, 1, 'bobel', $bobel_new)", __FILE__, __LINE__);

  }
  $bobel_select = $bobel_new;
}

// Call the function that has all the mood info
$bobel = MoodBobel();

// find out where we are and figure out how to get back
$str = getenv("QUERY_STRING");
if ($str)
  $action = 'index.php?'.$str;
else
  $action = 'index.php';

// print out the form
echo '
<form  accept-charset="', $context['character_set'], '" class="smalltext" style="padding: 0; margin: 8px 0 8px 0; text-align: center;" name="MoodBobel();"  id="MoodBobel();" action="'. $action . '" method="post" >
  <table><tr><td><b>', $txt['mood_bobel'], ':</b></td>
             <td><select name="bobel" onchange="MoodBobel();">
                 <option value=""></option>';

// Loop and show the drop down.
  foreach ($bobel as $key => $name)
    echo '
      <option value="', $key, '" ', ($bobel_select <> '' && $bobel_select == $key) ? 'selected="selected"' : '', '>', $name, '</option>';

  echo '</select></td></tr></table></ br>';
echo '
  <input type="submit" value="', $txt[10], '" />
  </form>';


DEMO LOOK:



A special thanks goes out to JPDeni for making this code possible!!! 

wilsy

Another great mod and TP block code - thanks M'Lord!!

Regards,

Wilsy.

Jakki


Lord Anubis

Cheers ;) , now if your using the mood stars here's the code

This code is for use the MOOD STARS V2.0 mod for SMF


global $db_prefix, $ID_MEMBER, $txt, $context;

$query = db_query(
    "SELECT value
     FROM {$db_prefix}themes
     WHERE ID_MEMBER = $ID_MEMBER
       AND variable LIKE 'star'", __FILE__, __LINE__);

if(db_affected_rows() != 0) {
  $row = mysql_fetch_assoc($query);
  $star_select = $row['value'];
}
else {
  $star_select = '';
}
//Has one been selected?
if(isset($_POST['star'])) {
  $star_new = $_POST['star'];
// There's already a mood selected
  if ($star_select <> '') {
    $query = db_query(
      "UPDATE {$db_prefix}themes
       SET value=$star_new
       WHERE ID_MEMBER = $ID_MEMBER
         AND variable LIKE 'star'
       LIMIT 1", __FILE__, __LINE__);
  }

// No mood previously selected
  else {
    $query = db_query(
      "INSERT INTO {$db_prefix}themes (ID_MEMBER, ID_THEME, variable, value)
       VALUES ($ID_MEMBER, 1, 'star', $star_new)", __FILE__, __LINE__);

  }
  $star_select = $star_new;
}

// Call the function that has all the mood info
$star = MoodStar();

// find out where we are and figure out how to get back
$str = getenv("QUERY_STRING");
if ($str)
  $action = 'index.php?'.$str;
else
  $action = 'index.php';

// print out the form
echo '
<form  accept-charset="', $context['character_set'], '" class="smalltext" style="padding: 0; margin: 8px 0 8px 0; text-align: center;" name="MoodStar();"  id="MoodStar();" action="'. $action . '" method="post" >
  <table><tr><td><b>', $txt['mood_star'], ':</b></td>
             <td><select name="star" onchange="MoodStar();">
                 <option value=""></option>';

// Loop and show the drop down.
  foreach ($star as $key => $name)
    echo '
      <option value="', $key, '" ', ($star_select <> '' && $star_select == $key) ? 'selected="selected"' : '', '>', $name, '</option>';

  echo '</select></td></tr></table></ br>';
echo '
  <input type="submit" value="', $txt[10], '" />
  </form>';


DEMO LOOK:


This website is proudly hosted on Crocweb Cloud Website Hosting.