Jump to content

magi

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

magi's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hey guys. I'm using MySql with PHP. Anyways i have a drop down box that gets a list from the db and displays it. I made a button so when i click it. A table appears with all the info. And it has a input box to put a new value you. Then once i click another button. Its supposed to update the DB with the new info. Ive been trying for ages and i cant seem to get it. It says its successful. However nothing is being updated. Any help would be appreciated. Thanks in advance if(isset($_POST[edithero])){ $get_hero_stuff=mysql_query("SELECT * FROM herodb WHERE Heroname='$hero_stuff[Heroname]'",$link ) or die(mysql_error()); $hero_stuff=mysql_fetch_array($get_hero_stuff); //all my checks here if ($check1==1&&$check2==1&&$check3==1&&$check4==1&&$check5==1&&$check6==1&&$check7==1&&$check8==1&&$check9==1&&$check10==1&&$check11==1&&$check12==1&&$check13==1&&$check14==1&&$check15==1&&$check15==1) { $hero_edit_update=mysql_query("UPDATE herodb SET HeroID='',Heroname='$_POST[heroname]') WHERE Heroname='$hero_stuff[Heroname]'",$link ) or die(mysql_error()); $success[]="Hero successfully edited"; } else{//print all the errors Heres my php and Mysql code and i cant figure it out. Its coming out as successfully updated and none of my input checks seem to catch anything/I think it may be the query at the beginning because im not selecting the right thing or somehting? Im not quite sure ive tried everything And heres the part you need of the other code echo'<table class="profiletb1"><tr class="rowcap1"><td colspan="2">Hero : </td></tr>'; echo'<tr><td class="admincellcen1" colspan="3">'.$hero_info[Heroname].'<select class="inputp" name="heromenu">'; $get_all_hname=mysql_query("SELECT * FROM herodb ORDER BY HeroID ASC",$link ) or die(mysql_error()); while ($all_hname=mysql_fetch_array($get_all_hname)) { echo"<option value='$all_hname[HeroID]'>$all_hname[Heroname]</option>"; } echo'</select></div></td></tr>'; echo'<tr><td class="admincellcen1" colspan="3"><div align="center"><input type="Submit" name="Edit_hero" value="Edit Hero"></div></td></tr></table>'; $get_hero_info=mysql_query("SELECT * FROM herodb WHERE HeroID='$_POST[heromenu]'",$link ) or die(mysql_error()); $hero_info=mysql_fetch_array($get_hero_info); echo'<table class="profiletb1"><tr class="rowcap1"><td colspan="2">Edit Hero</td></tr>'; echo'<tr><td class="admincellleft1">Name, title:<span class="littletextred1"><br>Accept only numbers, letters, spaces, hypens and commas</span>'; echo'<td class="admincellleft1">Current : '.$hero_info[Heroname].'<br><input class="inputp1" type="text" name="heroname" size="30" maxlength="40" value="'.$_POST[heroname].'"></td></tr>'; And theres the other part. Of course theres more things i want to add in the update feature. But if i cant get it to update one thing then whats the point of having it there So any help would be appreciated. Thanks
  2. Hey everyone, i am creating a calculator liek thing for an online game i run. I asked in the php thread and was told Javascript would be the best choice, however im not familiar with Javascript. What i have is echo' <td height="22">Race Selection:</td> <td height="22"><select class="inputp" name="Empiremenu">'; if ($_POST[Empiremenu]==1) $s1="selected"; if ($_POST[Empiremenu]==2) $s2="selected"; if ($_POST[Empiremenu]==3) $s3="selected"; if ($_POST[Empiremenu]==4) $s4="selected"; if ($_POST[Empiremenu]==5) $s5="selected"; if ($_POST[Empiremenu]==6) $s6="selected"; if ($_POST[Empiremenu]==7) $s7="selected"; if ($_POST[Empiremenu]== $s8="selected"; if ($_POST[Empiremenu]==9) $s9="selected"; echo'<option value="1" '.$s1.'>Dwarven (Lexima)</option>'; echo'<option value="2" '.$s2.'>Imperials (Lexima)</option>'; echo'<option value="3" '.$s3.'>Shinobi (Lexima)</option>'; echo'<option value="4" '.$s4.'>Templars (Celestial)</option>'; echo'<option value="5" '.$s5.'>Treefolk (Celestial)</option>'; echo'<option value="6" '.$s6.'>Avians (Celestial)</option>'; echo'<option value="7" '.$s7.'>Abominations (Hexion)</option>'; echo'<option value="8" '.$s8.'>Orcs (Hexion)</option>'; echo'<option value="9" '.$s9.'>Snowkin (Hexion) </option></select></td></tr>'; if($_POST[1]){echo' g-unit'; } What i want to happen is that when i change the option, i want the page to refresh and have the different text there as the unit. However i cannot get either to work so any help would be much appreciated.
  3. magi

    Hi

    OK Sorry, i will try to be a bit more clear. When you go to the page, a form appears with a selection box. In the selection box is different races. It first appears like this Race : (dropdown box with different races) Dwarven is the first one Unit: (this is the dwarvens first unit) Gnome Sapper What i want to happen is that when i change the dropdown box option the unit name will change according to what the race is.
  4. magi

    Hi

    That didnt seem to work, however i do have another question. I decided to try a different way to do this and it doesnt seem to be working. This way is much more efficient for me as i dont want to be doing 50 if statements. This was used on another page of mine and works fine but will not work on this page. <select class="inputBox" id="iRacePK0" name="D1" onchange="javascript:document.getElementById("myForm").submit()"><option value="1">Dwarven </option><option value="2">Imperials </option><option value="3">Shinobi </option><option value="4">Templars </option><option value="5">Treefolk </option><option value="6">Avian </option><option value="7">Abominations </option><option value="8">Orcs </option><option value="9">Snowkin </option></select> </td></tr><tr>'; $get_min_id=mysql_query("SELECT MIN(id) FROM mnamedb WHERE race= '$_POST[D1]'",$link ) or die(mysql_error()); $min_id=mysql_fetch_array($get_min_id); $m_details=mysql_query("SELECT * FROM mnamedb WHERE race = '$_POST[D1]' AND atk!=0 ORDER BY id ASC",$link ) or die(mysql_error()); while ($details=mysql_fetch_array($m_details)){ $m=$details[id]-$min_id[0]+1; if ($m==1) $m_num=m1; if ($m==2) $m_num=m2; if ($m==3) $m_num=m3; if ($m==4) $m_num=m4; if ($m==5) $m_num=m5; if ($m==6) $m_num=m6; // only show if current have troops of that type if ($newarray[$m_num]!=0){ echo'<tr class="admincell"><td><span onMouseover="ddrivetip(\'Offense:'.$details[3].'<br>Defense:'.$details[4].'<br>Mage:'.$details[6].'<br>Spy:'.$details[5].' \')" onMouseout="hideddrivetip()">'.$details[mname].'</span> </td>'; echo"<td>".number_format($newarray[$m_num])." </td>"; // display current troops strength echo'<td><input class="inputp" name="'.$m_num.'" type="text" size="5" maxlength="5" value="'.$_POST[$m_num].'"></td></tr>'; // display textbox } } $get_min_id=mysql_query("SELECT MIN(id) FROM mnamedb WHERE race= '$_POST[D1]'",$link ) or die(mysql_error()); $min_id=mysql_fetch_array($get_min_id); $m_details=mysql_query("SELECT * FROM mnamedb WHERE race = '$_POST[D1]' AND atk!=0 ORDER BY id ASC",$link ) or die(mysql_error()); while ($details=mysql_fetch_array($m_details)){ $m=$details[id]-$min_id[0]+1; if ($m==1) $m_num=m1; if ($m==2) $m_num=m2; if ($m==3) $m_num=m3; if ($m==4) $m_num=m4; if ($m==5) $m_num=m5; if ($m==6) $m_num=m6; // only show if current have troops of that type if ($newarray[$m_num]!=0){ echo'<tr class="admincell"><td><span onMouseover="ddrivetip(\'Offense:'.$details[3].'<br>Defense:'.$details[4].'<br>Mage:'.$details[6].'<br>Spy:'.$details[5].' \')" onMouseout="hideddrivetip()">'.$details[mname].'</span> </td>'; echo"<td>".number_format($newarray[$m_num])." </td>"; // display current troops strength echo'<td><input class="inputp" name="'.$m_num.'" type="text" size="5" maxlength="5" value="'.$_POST[$m_num].'"></td></tr>'; // display textbox This above code is the part that seems not to be working. Im not sure why it doesnt work though. It will display the text box in the wrong part of the code but the text box displays nonetheless, HOwever i cannot get any of the info from my query to appear with the text box, any help ?
  5. magi

    Hi

    Well i feel stupid now that that was all it was Now for the second part what i would like to do is when you change the selection in the box, it resets the page with the new data For example When you go to the page Racw: Dwarven Unit: Imps When you change the race to Imperials, it refreshes the page and puts Race: Imperials Unit: G's
  6. magi

    Hi

    NO, what i want to do is this I have a select list with different items. If i change the item to Dwarven it comes out like this Race: Dwarven Unit 1: Gnome Sapper then when i cange the race this appears Race: Templar Unit 1: Imperial
  7. magi

    Hi

    Well the thing i want is make it so that when the race Dwarven is picked, a certain unit name appears. And that if i change the race then the unit name changes to somehting else.
  8. magi

    Hi

    Anyone Help me ?
  9. magi

    Hi

    Hey Everyone, sorry to bother you but im having some problems. I am making a calculator for an online game to calculate attacks and things. However i cannot seem to get his part here to work. echo'<td align"left" width="155"> <select class="inputBox" id="iRacePK0" name="D1"> <option value="1">Dwarven </option><option value="2">Imperials </option><option value="3">Shinobi </option><option value="4">Templars </option><option value="5">Treefolk </option><option value="6">Avian </option><option value="7">Abominations </option><option value="8">Orcs </option><option value="9">Snowkin </option></select> </td></tr><tr>'; if(D1=='Dwarven'){ echo'<td align"left" width="155"> Gnome Sapper </td>'; }else if(D1==2){ echo'<td align"left" width="155"> Your Mom </td>'; } echo'<td align"left" width="155"><input type="hidden" name="unitpk1"><input type="hidden" name="totalunits1">'; echo'<input type="text" name="totalunitssent1" class="inputbox" value="0" maxlength="9" size="6"></td></tr><tr>'; What i am trying to do is if the select drop down box is a certain race, to put the unit name and then there is an input box. I also want it to change when a new race is selected but currently it only changes when my button is pressed. Any help ?
  10. Thanks all, i fixed it
  11. what i am trying to do is this , if(this condition && this condition are met ||(or) this condition) then display this otherwise display { this } so im almost sure id need an else statement there... As for posting it in parts and not whole, that is the part needed and being adjusted, my actual code is over 600 lines long and im sure you dont want it in here
  12. BUmp , sry but that did not seem to work, and like i said it only appears when i add that section. Anyone ?
  13. Well i am getting this error and it is rather annoying. It was all working fine untill i added a certain part and now that certain part is causing the error the part i added was this: if ($halftime[unify]=='Y'&&$halftime[Found_emp]=='Y'||($time_used>$halftime[u_time]+259200)) { echo'<table class="verifytb" style="width:500px"><tr class="tbhd"><td>Emperor Election</td></tr>'; echo'<tr><td class="admincellcen1">An Emporer has already been chosen, no more votes will be counted.</td></tr>'; } else { This is the rest of the section: // Display Creator Election Section if conditions met if ($newarray['Event']==1) { if ($halftime[unify]=='Y'&&$halftime[Found_emp]=='Y'||($time_used>$halftime[u_time]+259200)) { echo'<table class="verifytb" style="width:500px"><tr class="tbhd"><td>Emperor Election</td></tr>'; echo'<tr><td class="admincellcen1">An Emporer has already been chosen, no more votes will be counted.</td></tr>'; } else { echo'<table class="verifytb" style="width:500px"><tr class="tbhd"><td>Emperor Election</td></tr>'; echo'<tr><td class="admincellcen1">You can vote for a capable kingdom <b>in your empire</b> to represent as the Emperor for '.$newarray[empire].'</td></tr>'; // calculate how many ppl vote for this user $check_mine=mysql_query("SELECT COUNT(id) FROM users WHERE Svote= '$newarray[Knumber]'" ,$link ) or die(mysql_error()); $vote_for_me=mysql_fetch_array($check_mine); echo'<tr><td class="admincellleft1">--<b class="highlight">'.$vote_for_me[0].'</b> Kingdoms have voted you for the Emperor.<br>'; // Display current vote for creator if ($newarray['Svote']==0) echo'<span class="txtleft">-You have not vote for the Emperor yet.</span><br>'; else { $check_creator=mysql_query("SELECT Svote FROM users WHERE username = '$current'" ,$link ) or die(mysql_error()); $svote_no=mysql_fetch_array($check_creator); $check_creator2=mysql_query("SELECT kname FROM users WHERE Knumber = '$svote_no[0]'" ,$link ) or die(mysql_error()); $svote_name=mysql_fetch_array($check_creator2); // if vote for yourself then display differently if ($svote_name[0]!=$newarray[kname]) echo'--You have voted <b class="highlight">'.$svote_name[0].'</b> as the Emperor.<br>'; else echo'--You have voted yourself as the Emperor.<br>'; } echo"</td></tr>"; // user input realm number echo'<tr><td class="admincelltop1"><div align="center">Enter Realm Number of the kingdom you want to vote as Emperor:<input class="inputp" name="realm_no" type="text" size="4" maxlength="4">'; echo"<br><input type='Submit' name='realmchange' value='Locate Realm'></div></td></tr>"; // user presses the change realm button if(isset($_POST[realmchange])) { echo'<tr><td class="admincellcen1">Realm Number: <b class="hignlight">'.$_POST[realm_no].'</b>'; $check_tb=mysql_query("SELECT * FROM users WHERE RealmID = '$_POST[realm_no]' AND empire = '$newarray[empire]' ORDER BY land, NW DESC" ,$link ) or die(mysql_error()); $creator_tb=mysql_query("SELECT * FROM users WHERE RealmID = '$_POST[realm_no]' AND empire = '$newarray[empire]' ORDER BY land, NW DESC" ,$link ) or die(mysql_error()); $check_realm=mysql_fetch_array($check_tb); if (!$check_realm[0]) { // no records returned echo'<p><b class="highlight2">Invalid Realm number or Empire selection</b><br>'; } else { echo'<p><select class="inputp" name="creatormenu">'; while($realm_details=mysql_fetch_array($creator_tb)){ echo"<option>$realm_details[kname]</option>"; } echo"</select>"; echo'<br><input type="Submit" name="realmchange2" value="Vote for Emperor">'; } } echo"</td></tr></table>"; } else { echo'<table class="verifytb" style="width:500px"><tr class="tbhd"><td>Emperor Election</td></tr>'; echo'<tr><td class="admincellcen1">Your empire is not ready for the Emperor Election at the moment.</td></tr></table>'; } } Im not sure if theres too many else' or if im missing a brace or something, any help would be appreciated
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.