This code is for use the MOOD BOBELS V2.0 mod for SMF (http://custom.simplemachines.org/mods/index.php?mod=1195)
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:
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Ftinyadminresources.com%2Fextras%2Fimagehost%2Fscript%2Fuploads%2F90653510cb.png&hash=8d6da1e9030653b7c5b121235ab7a7e674dd9b19)
A special thanks goes out to JPDeni for making this code possible!!!
Another great mod and TP block code - thanks M'Lord!!
Regards,
Wilsy.
I love it...
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 (http://custom.simplemachines.org/mods/index.php?mod=1199)
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:
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Ftinyadminresources.com%2Fextras%2Fimagehost%2Fscript%2Fuploads%2F90653510cb.png&hash=8d6da1e9030653b7c5b121235ab7a7e674dd9b19)