Jump to content

Darkmatter5

Members
  • Posts

    422
  • Joined

  • Last visited

    Never

Posts posted by Darkmatter5

  1. I need a button that when pressed activates and runs the following code in the <input> form elements above in the same form.  The code for those is as follows

     

    <input type="text" name="abil_cha" size="2" value="<?php if(isset($_POST['reroll'])) { $werbgame->roll_dice(4,6,0,1); } ?>"> <?php echo substr($werb->getdata("descr","SELECT descr FROM d_abilities WHERE ability='charisma'"),0,50); ?>

     

    When the reroll button is pressed I'm wanting that PHP code to execute and generate the numbers.  The second button is the submit button that actually submits the data from the form to a script file.  As the code is right now it'll roll the numbers every time I press the reroll button.  If I put the code "<form method="post" action="pcb.php">" in the form tag it breaks the roll generation and submits the data to the the file as the action prescribes.  How can I get the submit button to submit the data and the reroll button to only make the the input form elements to regenerate new values?

     

    Thanks!

  2. Here's my php

     

    <form method="post">
      <input type="hidden" name="page" value="2">
      <table>
        <tr>
          <td align="right"><label for="abil_str">Str: </label></td>
          <td><input type="text" name="abil_str" size="2" value="<?php if(isset($_POST['reroll'])) { $werbgame->roll_dice(4,6,0,1); } ?>"> <?php echo substr($werb->getdata("descr","SELECT descr FROM d_abilities WHERE ability='strength'"),0,50); ?></td>
        </tr>
        <tr>
          <td align="right"><label for="abil_dex">Dex: </label></td>
          <td><input type="text" name="abil_dex" size="2" value="<?php if(isset($_POST['reroll'])) { $werbgame->roll_dice(4,6,0,1); } ?>"> <?php echo substr($werb->getdata("descr","SELECT descr FROM d_abilities WHERE ability='dexterity'"),0,50); ?></td>
        </tr>
        <tr>
          <td align="right"><label for="abil_dex">Con: </label></td>
          <td><input type="text" name="abil_con" size="2" value="<?php if(isset($_POST['reroll'])) { $werbgame->roll_dice(4,6,0,1); } ?>"> <?php echo substr($werb->getdata("descr","SELECT descr FROM d_abilities WHERE ability='constitution'"),0,50); ?></td>
        </tr>
        <tr>
          <td align="right"><label for="abil_dex">Int: </label></td>
          <td><input type="text" name="abil_int" size="2" value="<?php if(isset($_POST['reroll'])) { $werbgame->roll_dice(4,6,0,1); } ?>"> <?php echo substr($werb->getdata("descr","SELECT descr FROM d_abilities WHERE ability='intelligence'"),0,50); ?></td>
        </tr>
        <tr>
          <td align="right"><label for="abil_dex">Wis: </label></td>
          <td><input type="text" name="abil_wis" size="2" value="<?php if(isset($_POST['reroll'])) { $werbgame->roll_dice(4,6,0,1); } ?>"> <?php echo substr($werb->getdata("descr","SELECT descr FROM d_abilities WHERE ability='wisdom'"),0,50); ?></td>
        </tr>
        <tr>
          <td align="right"><label for="abil_dex">Cha: </label></td>
          <td><input type="text" name="abil_cha" size="2" value="<?php if(isset($_POST['reroll'])) { $werbgame->roll_dice(4,6,0,1); } ?>"> <?php echo substr($werb->getdata("descr","SELECT descr FROM d_abilities WHERE ability='charisma'"),0,50); ?></td>
        </tr>
        <tr><td colspan="2" align="center"><input type="submit" name="reroll" value="Reroll"> <input type="submit" name="submit" value="Submit"></td></tr>
      </table>
    </form>
    

     

    Now the reroll button works like this, but what if I want to submit the rolls to a script as the form action?  If I include the following code "<form method="post" action="scripts/pcb.php">" it breaks the roll button.  How can I get both to work within this form?  Thanks!

  3. Here's my CSS

    #content { padding: 1em; width: 75%; position: relative; background-color: green; }
    #form_mainwrapper { width: 45%; }
    #form_maintitle { width: 100%; padding: 5px; border-top: 2px solid black; border-left: 2px solid black; border-right: 2px solid black; border-bottom: 1px solid black; font-weight: bold; font-size: 14px; }
    #form_maintable { width: 100%; min-height: 200px; padding: 5px; border-left: 2px solid black; border-right: 2px solid black; }
    #form_mainfooter { width: 100%; padding: 5px; border-top: 1px solid black; border-left: 2px solid black; border-right: 2px solid black; border-bottom: 2px solid black; text-align: center; }
    

     

    Here's the PHP file

    <div id="content" style="float:left;">
      <p style="padding:.5em; border-bottom:1px solid #808000;"><span class="title_text">"<?php echo "$game_title"; ?>" player character builder</span><br>
      On this page you can create and edit your player characters.</p>
      <div id="form_mainwrapper" style="float:left;">
        <form name="page1" method="post">
        <div id="form_maintitle" style="background-color:#D3D3D3;">Step 1: Naming and class selection</div>
        <div id="form_maintable" style="background-color:#D3D3D3;">
          <p><label for="firstname">First name: </label><input type="text" name="firstname" size="50" value="<?php if(isset($_GET['id'])) { $werb->getdata("forename","SELECT forename FROM player_characters WHERE character_id='$_GET[id]'"); } ?>" disabled="disabled" ></p>
          <p><label for="lastname">Last name: </label><input type="text" name="lastname" size="50" value="<?php if(isset($_GET['id'])) { $werb->getdata("surname","SELECT surname FROM player_characters WHERE character_id='$_GET[id]'"); } ?>" disabled="disabled" ></p>
          <p><label for="class">Class: </label><?php $werb->dropdown("class","SELECT class_id, class FROM d_classes ORDER BY class ASC","","showClassdescr"); ?></p>
          <div style="width:100%;">Class description:</div>
          <div id="class_descr" style="width:100%; color:#B22222; background-color:#D3D3D3;"><i><b>Class description will display here when a class is chosen.</b></i></div>
        </div>
        <div id="form_mainfooter" style="background-color:#D3D3D3;"><input type="submit" name="submitp1" value="Submit step 1"></div>
        </form>
      </div>
      <div id="form_mainwrapper" style="float:right;">
        <form name="page2" method="post">
        <div id="form_maintitle" style="background-color:#F0E68C;">Step 2: Naming and class selection</div>
        <div id="form_maintable" style="background-color:#F0E68C;">
          <p><label for="firstname">First name: </label><input type="text" name="firstname" size="50" value="<?php if(isset($_GET['id'])) { $werb->getdata("forename","SELECT forename FROM player_characters WHERE character_id='$_GET[id]'"); } ?>" disabled="disabled" ></p>
          <p><label for="lastname">Last name: </label><input type="text" name="lastname" size="50" value="<?php if(isset($_GET['id'])) { $werb->getdata("surname","SELECT surname FROM player_characters WHERE character_id='$_GET[id]'"); } ?>" disabled="disabled" ></p>
          <p><label for="class">Class: </label><?php $werb->dropdown("class","SELECT class_id, class FROM d_classes ORDER BY class ASC","","showClassdescr"); ?></p>
          <div style="width:100%; float:left;">Class description: </div> <div id="class_descr" style="width: 250px; color: #B22222; float: left;"><i><b>Class description will display here when a class is chosen.</b></i></div>
        </div>
        <div id="form_mainfooter" style="background-color:#F0E68C;"><input type="submit" name="submitp1" value="Submit step 1"></div>
        </form>
      </div>
    </div>
    

     

    The div that contains page 2 bleeds outside the content div. What's wrong? See the attached screen shot to see what I'm talking about.

     

    [attachment deleted by admin]

  4. Here's the HTML

    <script type="text/javascript" src="/library/scripts/selectclass.js" /></script>
    
    <select name='class' method='get' class='text_boxes' onchange='showClassdescr(this.value)'>
    <option value='6'>Charismatic</option>
    <option value='5'>Dedicated</option>
    <option value='2'>Fast</option>
    <option value='4'>Smart</option>
    <option value='1'>Strong</option>
    <option value='3'>Tough</option>
    </select>
    <div id="class_descr"><b>Class description will display here when a class is chosen.</b></div>
    

     

    Here's the Javascript file

    var xmlhttp
    
    function showClassdescr(str) {
        xmlhttp=GetXmlHttpObject();
        if (xmlhttp==null) {
            alert ("Your browser does not support AJAX!");
            return;
        }
        var url="/library/scripts/getclassdescr.php";
        url=url+"?q="+str;
        url=url+"&sid="+Math.random();
        xmlhttp.onreadystatechange=stateChanged;
        xmlhttp.open("GET",url,true);
        xmlhttp.send(null);
    }
    
    function stateChanged() {
        if (xmlhttp.readyState==4) {
            document.getElementById("class_descr").innerHTML=xmlhttp.responseText;
        }
    }
    
    function GetXmlHttpObject() {
        if (window.XMLHttpRequest) {
            // code for IE7+, Firefox, Chrome, Opera, Safari
            return new XMLHttpRequest();
        }
        if (window.ActiveXObject) {
            // code for IE6, IE5
            return new ActiveXObject("Microsoft.XMLHTTP");
        }
        return null;
    }
    

     

    Here's the getclassdescr.php file

    <?php
      include_once('library/config.php');
      
      $q=$_GET["q"];
      $result=mysql_query("SELECT descr FROM classes WHERE class_id='$q'");
      while($row=mysql_fetch_array($result)) { echo "$row[descr]"; }
    ?>
    

     

    Here's the file locations

    pcbuilder.php

    /library/config.php

    /library/scripts/getclassdescr.php

    /library/scripts/selectclass.js

     

    When I change the selection it does nothing.  How can I test this a piece at a time or does anyone readily see the error?  Thanks!

  5. Here's the code in question

    <div id="content" style="float: left;">
      <p style="padding: .5em; border-bottom: 1px solid #808000;"><span class="title_text">"<?php echo "$game_title"; ?>" profile for <?php echo $werb->getusername($_SESSION['member_id']); ?></span><br>
      On this page you can edit anything in regards to your account settings. You can also add and delete characters from your profile.</p>
      <div style="width: 100%; background-color: green; position: relative;">
        <div style="float: left; width: 40% height: 120px;">
          <b>BUILDERS</b><br>
          <ul>
          <li><a href="res_tools-modbuilder.php">Module Builder</a></li>
          <li><a href="res_tools-pcbuilder.php">Player Character Builder</a></li>
          <li><a href="res_tools-npcbuilder.php">Non-Player Character Builder</a></li>
          </ul>
          <b>USER TOOLS</b><br>
          <ul>
          <li>TEST</li>
          </ul>
        </div>
        <div style="float: right; width: 40%; height: 120px; padding: 1em; border: 2px solid #2F4F4F;">
          <b>Your chatacters</b><br>
          <?php $werb->list_pcs($_SESSION['member_id']); ?>
        </div>
      </div>
      <div style="width: 100%; background-color: blue;">TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST</div>
    </div>
    <div id="roundedBox" class="roundedBox" style="float: right; width: 200px; padding: 0 1em 0 1em";>
      <table width="100%" cellpadding="2" cellspacing="0" border="0">
        <tr><th style="border-bottom: 2px groove #F0FFF0;">TEMP HOLDER</th></tr>
        <tr valign="top"><th> </th></tr>
      </table>
      <div class="corner topLeft"></div>
      <div class="corner topRight"></div>
      <div class="corner bottomLeft"></div>
      <div class="corner bottomRight"></div>
    </div>

     

    I'm wanting the green div be above the blue div.  I also need the left and right floated divs to be wrapped by the green div.  The green div doesn't appear and the blue div renders on top of where the green div should be.

     

    [attachment deleted by admin]

  6. Here's my code

    <?php
        include_once('library/config.php');
        include_once('library/werb_funcs.php');
        include_once('library/werbgame_funcs.php');
        $werb=new werb();
        $werbgame=new werbgame();
        $page="index";
        
        ob_start();
        if(!isset($_SESSION['member_id'])) {
            ob_end_clean();
            //header("Location: index.php");
        }
        session_start();
        
        require_once('page_beg.php');
    ?>
    

     

    I'm basically wanting to check if a session is created for the site on the current viewing browser and if it's been created with member_id, then the user is logged in and they may view the page, if the session doesn't exist then redirect the users browser to index.php.  If I uncomment the header code, no matter what the browser is redirected to index.php.  Where should I put that line to accomplish what I'm needing also any critique on the code is always welcome.

  7. config.php is in "public_html/library"

    funcs.php is in "public_html/library"

    index.php is in "public_html"

     

    Here's config.php

    <?php
      $admin_email="****";
      $url="http://www.mysite.com";
      $dbhost="localhost";
      $dbuser="user";
      $dbpass="pass";
      $dbname="name";
    ?>

     

    Here's funcs.php

    <?php
      class werb {
        function page_theme() {
          include_once('config.php');
          echo "dbhost: $dbhost";
        }
      }
    ?>

     

    Here's index.php

    <?php
      include('library/config.php');
      require_once('library/funcs.php');
      $werb=new werb();
      $werb->page_theme();
    ?>

     

    All I get from loading index.php is:

    dbhost:

     

    It should be:

    dbhost: localhost

     

    What's wrong?

  8. Okay here's an actual example I've come up with.  See if you can help me.

     

    player_characters

    character_idexperience

    1800

     

    levels

    levelfloor_expceiling_exp

    10500

    25011000

    310011500

     

    Here's my trigger code

    DELIMITER $$
    
    CREATE
        /*[DEFINER = { user | CURRENT_USER }]*/
        TRIGGER `thealien_aftermath`.`update_level` AFTER UPDATE
        ON `thealien_aftermath`.`player_character`
        FOR EACH ROW BEGIN
    
    DECLARE level INTEGER;
    SELECT l.level
    INTO level
    FROM player_characters AS pc, levels AS l
    WHERE pc.character_id=NEW.character_id
    AND pc.experience BETWEEN l.floor_exp ANd l.ceiling_exp
    
    UPDATE player_characters AS pc
    SET pc.level=level
    WHERE pc.character_id=NEW.character_id
    
        END$$
    
    DELIMITER ;
    

     

    I'm wanting to have the level be updated to player_character.level when the character record is updated.  I'm getting this error:

     

    Error Code : 1064

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE player_characters AS pc

    SET pc.level=level

    WHERE pc.character_id=NEW.char' at line 12

     

  9. Yes you are right, but I'm wanting to learn triggers and I'm not getting much from googled tutorials.  There's nothing I've found so far that has clear instructions.  So I created this scenario to inquire as to how it might be accomplished.

     

    Thanks for the reply.

  10. I understand pretty much nothing about triggers.  They're syntax is quite confusing.  So i'm asking for someone to help me build this query and help explain to me what it's doing if possible.

     

    I need the trigger to run after a record is updated.  I need it to get the current score grade based on what the current grade amount is.  So if a students record is updated from 72 to 85 and the score grades are listed in the following table

     

    grademinmax

    A90100

    B8089

    C7079

    F069

     

    The students grade should now be set to B from C.  I know how to get the grade based on the score, but don't know how to build this trigger.

     

    Thanks!

  11. I have 2 tables

     

    grading_system

    grademin_score

    A90

    B80

    C70

    D60

    F0

     

    tests

     

    test_idscore

    182

    275

    390

    495

    596

     

     

    How can I use the grading_system table to determine the following outcome?  Or how should I better design my grading_system table to accomplish this?

     

    Test 1: 82% = B

    Test 2: 75% = C

    Test 3: 90% = A

    Test 4: 95% = A

    Test 5: 96% = A

     

    Thanks!

  12. I've got a page that has images for div corners to produce rounded edges.  The inside color of the rounded edge image is the same color code I use for the div background color, so it should match and look like a solid round edged box.  Firefox displays the colors wonderfully, but IE doesn't the color in the images are slightly darker then the color of the div background.  attached is a screen shot of the effect.  Is there any way to fix this?

     

    [attachment deleted by admin]

  13. I've been experimenting with making round edged divs and I got it working, but with my current code the divs displayed below the rounded div are being overlapped by the round edged div.  Attached is a screen shot of the output.

     

    Here's my html

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta name="verify-v1" content="b9XukIhbqIeyVH3ohFrrSqcFNNoE4GfQt8uCzrZ3k80=" />
    <meta name="description" content="Video game and movies trading" />
    <meta name="keywords" content="360,wii,ps2,ps3,xbox,dvd,nintendo,sony,microsoft,video game,video games,movie,movies,trading,video,entertainment" />
    <meta name="author" content="" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>V.E.I.N. - "Where the thumb meets the controller"</title>
    <link href='styles/white_config.css' rel='stylesheet' type='text/css'>
    <link href='styles/white_divs.css' rel='stylesheet' type='text/css'>
    </head>
    
    <body>
    <div id="wrap">
      <div id="header">header</div>
      <div id="status">
        <div id="theme1" class="roundedBox" style="float: left; width: 175px; height: 100%; padding: 0 1em 0 1em;">
          <div class="corner topLeft"></div>
          <div class="corner topRight"></div>
          <div class="corner bottomLeft"></div>
          <div class="corner bottomRight"></div>
        </div>
      </div>
      <div id="navcontainer">navcontainer</div>
      <div id="content">content</div>
    </body>
    
    </html>
    

     

    Here's the CSS file

    #wrap {
        width: 1000px;
        /*min-height: 100%;*/
        position: relative;
        padding-left: 5px;
        padding-right: 5px;
        margin: 0 auto;
        background-color: White;
        -moz-opacity: 0.95;
        filter: alpha(opacity=95);
        opacity: .95;
    }
    #header {
        position: relative;
        height: 70px;
        width: 100%;
        /*border-bottom: 1px solid;*/
        /*background-color: gray;*/
    }
    #status {
        height: 100px;
        width: 100%;
        /*border-bottom: 1px solid;*/
        /*background-color: red;*/
    }
    #navcontainer {
        line-height: 2.5em;
        height: 30px;
        width: 100%;
        border-bottom: 1px solid;
        background-color: fuchsia;
    }
    #content {
        padding: 1em;
        /*background-color: blue;*/
    }
    /*- Rounded-cornered divs -*/
    .roundedBox { position: relative; padding: 11px; margin: 10px 0; }
        /*- All the corners -*/
        .corner { position: absolute; width: 11px; height: 11px; }
        /*- Each corner -*/
        .topLeft { top: 0; left: 0; background-position: -1px -1px; }
        .topRight { top: 0; right: 0; background-position: -13px -1px; }
        .bottomLeft { bottom: 0; left: 0; background-position: -1px -13px; }
        .bottomRight { bottom: 0; right: 0; background-position: -13px -13px; }
    
    /*- Theme 1 - White -*/
    #theme1 { background-color: #2B3349; }
        #theme1 .corner { background-image: url(../images/borders/corners-theme1.png); }
    

     

    So as you can see from the screen shot, the navcontainer div doesn't display below the status div enough to display correctly.  I hope that was all the code you might need to help troubleshoot!

     

    [attachment deleted by admin]

  14. If I have the login credentials to another site in a database and know the form name and element name, can you make a link on your own site that when clicked takes you to the other site and auto fills the form elements in with the data from the database?

     

    Not sure if this is PHP or not, so if it's not a PHP question sorry!

  15. Here's the query I have so far

     

    SELECT g.game_id, g.title, s.name

    FROM games AS g

    Inner Join game_systems AS gs ON gs.game_id = g.game_id

    Inner Join systems AS s ON s.system_id = gs.system_id

    WHERE g.admin_approved =  '0'

    ORDER BY g.title ASC, gs.game_id ASC, s.name ASC

     

    Here's the current result

    game.id title                      systems

    49        Bionic Commando PC

    49        Bionic Commando Playstation 3

    49        Bionic Commando Xbox 360

    51        Bionic Commando Wii

    52        Bionic Commando Nintendo DS

     

    I'm wanting to list each title grouped together, but concat the systems together to something like this.

    game.id title                      systems

    49        Bionic Commando      PC, Playstation 3, Xbox 360

     

    How can I do that?

×
×
  • 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.