Reply
Using options with PHP ~_~"
Old 03-27-2006, 09:42 PM Using options with PHP ~_~"
Ickie's Avatar
Extreme Talker

Posts: 217
Location: Australia
PHP Code:
$rank $profile[rank];
echo (
"<form name=\"rank\" method=\"post\">");
if (
$rank == 1) {
    
$rank "Member";
    echo (
"<select name=\"rank\">
    <option selected=\"selected\" value=\"$rank\">$rank
    <option value=\"Moderator\">Moderator
    <option value=\"Administrator\">Administrator
    </select>"
);
    }
if (
$rank == 2) {
    
$rank "Moderator";
    echo (
"<select name=\"rank\">
    <option value=\"Member\">Member
    <option selected=\"selected\" value=\"$rank\">$rank
    <option value=\"Administrator\">Administrator
    </select>"
);
    }
if (
$rank == 3) {
    
$rank "Administrator";
    echo (
"<select name=\"rank\">
    <option value=\"Member\">Member
    <option value=\"Moderator\">Moderator
    <option selected=\"selected\" value=\"$rank\">$rank
    </select>"
);
    }
echo (
"</form>"); 
This is my small script for changing a user's rank on admin page, I was wondering how you could make it automatically run PHP after you changed the option, so I want it to be able to run without you need to press a submit button.
Ickie is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 03-27-2006, 10:18 PM Re: Using options with PHP ~_~"
QuickTim's Avatar
Average Talker

Posts: 16
Code:
onchange="javascript: {script to submit form}"
im not a java expert but i do know this should work, put it in the <select> tag. replace "{script to submit form}" with a script that will submit the form, and bingo you have it working. the only reason i did "{script to submit form}" was because i dont know that
QuickTim is offline
Reply With Quote
View Public Profile Visit QuickTim's homepage!
 
Old 03-27-2006, 11:32 PM Re: Using options with PHP ~_~"
Ickie's Avatar
Extreme Talker

Posts: 217
Location: Australia
PHP Code:
$rank $profile[rank];
echo (
"<br />Rank:<form method=\"post\">");
if (
$rank == 1) {
    
$rank "Member";
    echo (
"<select name=\"rank\">
    <option name=\"1\" selected=\"selected\" value=\"1\">$rank
    <option name=\"2\" value=\"2\">Moderator
    <option name=\"3\" value=\"3\">Administrator
    </select>"
);
    }
if (
$rank == 2) {
    
$rank "Moderator";
    echo (
"<select name=\"rank\">
    <option name=\"1\" value=\"1\">Member
    <option name=\"2\" selected=\"selected\" value=\"2\">$rank
    <option name=\"3\" value=\"3\">Administrator
    </select>"
);
    }
if (
$rank == 3) {
    
$rank "Administrator";
    echo (
"<select name=\"rank\">
    <option name=\"1\" value=\"1\">Member
    <option name=\"2\" value=\"2\">Moderator
    <option name=\"3\" selected=\"selected\" value=\"3\">$rank
    </select>"
);
    }
if (
$_POST[update])

if (
$_POST['1']) {
$rank "1";

if (
$_POST['2']) {
$rank "2";
}
if (
$_POST['3']) {
$rank "3";
}
mysql_query("UPDATE users SET rank = '$rank' WHERE username = '$profile[username]'") or die(mysql_error());
}
echo (
"<br />Real Name: $profile[name]<br />
Location: $profile[location]<br />
Paypal: $profile[paypal]<br />
Email: $profile[email]<br /><br />
Registered on: $profile[date]<br /><br />
<input type=\"submit\" name=\"update\" value=\"Update\"> <input type=\"submit\" name=\"delete\" value=\"Delete\">
</form> 
I've decided just to make it a update button, this kind of works. It's weird, it will remove all other information in the database and will make the rank = 0... when the default is 1.

Last edited by Ickie : 03-28-2006 at 01:23 AM.
Ickie is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Using options with PHP ~_~"
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13752 seconds with 12 queries