Dark Jim
08-29-2002, 11:14 PM
I'm working on a RPG hack and created a new table called "rpg_user". In that table you have "userid" and various stuff such as "exp", "hp" and more. I created a file "rpgadmin.php" and now when $action=modifyuser you can enter the name of the user you want to edit. I can't figure out how to get all data from that user in the table "rpg_user" by entering a name. Could someone help? :ermm: Note that I know almost no php or mysql and this is just trying and seeing what happens what I'm doing. :p Although by doing so and by looking at other's code you'll learn too. :)
Btw here is what I have so far. Also I want it so that after you modified options, the page should go back to "options" and when you editted a user the page should go back to "modifyuser". I looked at how this was done in other hacks but still I can't get it working. :(
<?php
error_reporting(7);
require("./global.php");
cpheader();
if (isset($action)==0) {
$action="options";
}
// ###################### Edit options #######################
if ($action=="options") {
doformheader("rpgadmin","updateoptions");
$rpgopt=$DB_site->query_first("SELECT * FROM rpg_options");
if ($rpgopt[enable]=="1") {
$enableyes="checked";
$enableno="";
} else {
$enableyes="";
$enableno="checked";
}
maketableheader("Edit RPG Options","",0);
echo "<tr class='".getrowbg()."' valign='top'>";
echo "<td><p>Enable RPG feature</p></td>";
echo "<td><p>Yes<input type='radio' name='enable' value='1' $enableyes> No <input type='radio' name='enable' value='0' $enableno></p></td></tr>";
doformfooter('Save changes');
}
// ###################### Update Options #######################
if ($action=="updateoptions") {
$DB_site->query("UPDATE rpg_options SET enable=$enable");
echo "<p>RPG Options updated!</p>";
$action="options";
}
// ###################### Modify user #######################
if ($action=="modifyuser") {
doformheader("rpgadmin","edituser");
makeinputcode("User Name contains","ausername");
doformfooter('Edit User');
}
// ###################### Edit user #######################
if ($action=="edituser") {
doformheader("rpgadmin","updateuser");
$userstats=$DB_site->query_first("SELECT <What goes here?> ");
makeinputcode("Experience","exp","$userstats[exp]");
doformfooter('Save changes');
}
// ###################### Update Selected user #######################
if ($action=="updateuser") {
$DB_site->query("UPDATE rpg_user SET exp=$exp WHERE userid=$auser");
echo "<p>RPG User Options updated!</p>";
$action=="edituser";
}
cpfooter();
?>
Btw here is what I have so far. Also I want it so that after you modified options, the page should go back to "options" and when you editted a user the page should go back to "modifyuser". I looked at how this was done in other hacks but still I can't get it working. :(
<?php
error_reporting(7);
require("./global.php");
cpheader();
if (isset($action)==0) {
$action="options";
}
// ###################### Edit options #######################
if ($action=="options") {
doformheader("rpgadmin","updateoptions");
$rpgopt=$DB_site->query_first("SELECT * FROM rpg_options");
if ($rpgopt[enable]=="1") {
$enableyes="checked";
$enableno="";
} else {
$enableyes="";
$enableno="checked";
}
maketableheader("Edit RPG Options","",0);
echo "<tr class='".getrowbg()."' valign='top'>";
echo "<td><p>Enable RPG feature</p></td>";
echo "<td><p>Yes<input type='radio' name='enable' value='1' $enableyes> No <input type='radio' name='enable' value='0' $enableno></p></td></tr>";
doformfooter('Save changes');
}
// ###################### Update Options #######################
if ($action=="updateoptions") {
$DB_site->query("UPDATE rpg_options SET enable=$enable");
echo "<p>RPG Options updated!</p>";
$action="options";
}
// ###################### Modify user #######################
if ($action=="modifyuser") {
doformheader("rpgadmin","edituser");
makeinputcode("User Name contains","ausername");
doformfooter('Edit User');
}
// ###################### Edit user #######################
if ($action=="edituser") {
doformheader("rpgadmin","updateuser");
$userstats=$DB_site->query_first("SELECT <What goes here?> ");
makeinputcode("Experience","exp","$userstats[exp]");
doformfooter('Save changes');
}
// ###################### Update Selected user #######################
if ($action=="updateuser") {
$DB_site->query("UPDATE rpg_user SET exp=$exp WHERE userid=$auser");
echo "<p>RPG User Options updated!</p>";
$action=="edituser";
}
cpfooter();
?>