Jump to content

papaface

Members
  • Posts

    1,437
  • Joined

  • Last visited

    Never

Posts posted by papaface

  1. That will get so irreparably sloppy in a short amount of time that it's easier to just fix the underlying issue.

    Yeah I totally agree, but that wasn't my point. It is valid PHP code.

    OPs question:

    Can you do an if else statment in an echo? Pretty much i want to do and if else statment to hide empty fields.

    The answer. Yes:

    Conditional statements in echo's are quite easily possible:

    <?php
    $num = 1;
    echo "\$num has a value of 10? " . ($num == '10' ? 'True' : 'False');
    ?>

    Apply to your code as necessary.

    Question answered, mark as solved.

  2. That was going to be my suggestion too :P

    Can you tell me though, with the case what if you have a multi line block of code to run in each case do you just put it in parenthesis with the break inside it? I can't remember and haven't done it in a while (but I'm going to switch most of my site over the the switch, case, default method of comparisons soon).

    Would be:

    <?php
    
    switch($positoin){
    
       case 1: $style = 'A lot
    of code';
       echo 'A lot of code';
       break;
    
       case 1: $style = 'A lot
    of code';
       echo 'A lot of code';
       break;
    
       case 1: $style = 'A lot
    of code';
       echo 'A lot of code';
       break;
    
       case 1: $style = 'A lot
    of code';
       echo 'A lot of code';
       break;
    }
    ?>

    No { } needed

  3. not really.

     

    www.PhonePwners.com is my website (im working on it)

    and want it where I can click any of the nav links

    and have them like index?=1 - 5

    instead of contact.php, call.php, sound.php, ect.

     

     

    i dont really care about search eng. and stuff..

    I am well aware of what you want. But its your grave.
  4. <tr>

    <td class="box" style="border-bottom: 1px solid rgb(52, 73, 102);" width="167">

     

    <a href="contact.php">Contact</a></td>

    </tr>

     

    That is what I have so far, how can i change it where like contact is index.php?=1

    The way you are trying to do it is bad for search engines, also it not very user friendly. In order for me to quickly go to your page I have to know the internal number reference. Whereas, tutorials are at tutorials.php. Catch my drift?
  5. Try:

    <HTML>
    <TITLE>
    RJSWS - mafia Wars
    </TITLE>
    <body>
    <font face=verdana size=2>
    
    <?php
    
    foreach ($_POST as $k => $v)
    {
      if (!isset($_POST[$k]) || trim($_POST[$k]) == "" || $_POST[$k] == "" )
       {
          $_POST[$k] = 0;
       }
    }
    
    $a_lot_price = $_POST['a_lot_price'] ;
    $a_lot_base = 0 ;
    $a_lot_rent = 100 ;
    $a_lot_sum_a = $a_lot_price+$a_lot_base ;
    $a_lot_sum = $a_lot_sum_a/$a_lot_rent ;
    $a_lot_sum_for = number_format($a_lot_sum, 0);
    
    
    $c_lot_price = $_POST['c_lot_price'] ;
    $c_lot_base = 0 ;
    $c_lot_rent = 300 ;
    $c_lot_sum_a = $c_lot_price+$c_lot_base ;
    $c_lot_sum = $c_lot_sum_a/$c_lot_rent ;
    $c_lot_sum_for = number_format($c_lot_sum, 0);
    
    $p_lot_price = $_POST['p_lot_price'] ;
    $p_lot_base = 0 ;
    $p_lot_rent = 2000 ;
    $p_lot_sum_a = $p_lot_price+$p_lot_base ;
    $p_lot_sum = $p_lot_sum_a/$p_lot_rent ;
    $p_lot_sum_for = number_format($p_lot_sum, 0);
    
    $b_lot_price = $_POST['b_lot_price'] ;
    $b_lot_base = 0 ;
    $b_lot_rent = 8000 ;
    $b_lot_sum_a = $b_lot_price+$b_lot_base ;
    $b_lot_sum = $b_lot_sum_a/$b_lot_rent ;
    $b_lot_sum_for = number_format($b_lot_sum, 0);
    
    $r_prop_price = $_POST['r_prop_price'] ;
    $r_prop_base = 5000 ;
    $r_prop_rent = 300 ;
    $r_prop_sum_a = $r_prop_price+$r_prop_base ;
    $r_prop_sum = $r_prop_sum_a/$r_prop_rent ;
    
    ?>
    <head>
    <title></title>
    
    <style type="text/css">
    
    
    tr.a {
    background-color: Aqua;
    }
    
    tr.a1 {
    background-color: lime;
    }
    
    td.b {
    color: black;
    width: 200px;
    }
    
    .lot_value {
    color: red;
    text-align: center;
    }
    
    td.c_title {
    color: black;
    width: 150px;
    text-align: center;
    }
    
    tr.blank {
    background-color: black;
    height: 3px;
    }
    
    </style>
    
    </head>
    
    <body>
    <form method=post action=mafia_prices.php>
    
    <table>
    <tr class="a">
    <td class="c_title"></td>
    <td class="c_title">Price Per Lot</td>
    </tr>
    <tr class="a">
    <td class="b">Abandoned Lot</td>
    <td class="c"><input type="text" class="lot_value" name=a_lot_price size="20" value="<? echo $a_lot_price; ?>"></td>
    <td class="d"><input type="text" class="lot_value" name=a_lot_per size="20" value="$<? echo $a_lot_sum_for; ?>"></td>
    </tr>
    <tr class="a1">
    <td class="b">Commercial Block</td>
    <td class="c"><input type="text" class="lot_value" name=c_lot_price size="20" value="<? echo $c_lot_price; ?>"></td>
    <td class="d"><input type="text" class="lot_value" name=c_lot_per size="20" value="$<? echo $c_lot_sum_for; ?>"></td>
    </tr>
    <tr class="a">
    <td class="b">Prime Downtown Lot</td>
    <td class="c"><input type="text" class="lot_value" name=p_lot_price size="20" value="<? echo $p_lot_price; ?>"></td>
    <td class="d"><input type="text" class="lot_value" name=p_lot_per size="20" value="$<? echo $p_lot_sum_for; ?>"></td>
    </tr>
    <tr class="a1">
    <td class="b">Beachfront Property</td>
    <td class="c"><input type="text" class="lot_value" name=b_lot_price size="20" value="<? echo $b_lot_price; ?>"></td>
    <td class="d"><input type="text" class="lot_value" name=b_lot_per size="20" value="$<? echo $b_lot_sum_for; ?>"></td>
    </tr>
    <tr class="blank">
    <td></td>
    <td></td>
    </tr>
    <tr class="a">
    <td class="b">Rent House</td>
    <td class="c"><input type="text" class="lot_value" name="r_prop_price" size="20" value="<?php echo $r_prop_price; ?>"></td>
    <td class="d"><input type="text" class="lot_value" name="r_prop_per" size="20" value="$<?php echo $r_prop_sum_for; ?>"></td>
    </tr>
    <tr class="a1">
    <td class="b">Italian Restaurant</td>
    <td class="c"><input type="text" class="lot_value" name="i_prop" size="20" value=""></td>
    </tr>
    <tr class="a">
    <td class="b">Apartment Complex</td>
    <td class="c"><input type="text" class="lot_value" name="a_prop" size="20" value=""></td>
    </tr>
    <tr class="a1">
    <td class="b">Valu-Mart</td>
    <td class="c"><input type="text" class="lot_value" name="v_prop" size="20" value=""></td>
    </tr>
    <tr class="a">
    <td class="b">Office Building</td>
    <td class="c"><input type="text" class="lot_value" name="o_prop" size="20" value=""></td>
    </tr>
    <tr class="a1">
    <td class="b">5-Star Hotel</td>
    <td class="c"><input type="text" class="lot_value" name="5_prop" size="20" value=""></td>
    </tr>
    <tr class="a">
    <td class="b">Mega Casino</td>
    <td class="c"><input type="text" class="lot_value" name="m_prop" size="20" value=""></td>
    </tr>
    </table>
    <input type=submit value="Submit" >
    </form>
    </body>
    </html>
    
    
    
    
    </font>
    </body>
    </HTML>
    

  6. change to:

    <td class="c"><input type="text" class="lot_value" name="r_prop_price" size="20" value="<?php echo $r_prop_price; ?>"></td>
    <td class="d"><input type="text" class="lot_value" name="r_prop_per" size="20" value="$<?php echo $r_prop_sum_for; ?>"></td>
    

    and try:

    foreach ($_POST as $k => $v)
    {
      if ($v == "")
       {
          $_POST[$k] = 0;
       }
    }
    $r_prop_price = $_POST['r_prop_price'] ;
    $r_prop_base = 5000 ;
    $r_prop_rent = 300 ;
    $r_prop_sum_a = $r_prop_price+$r_prop_base ;
    $r_prop_sum = $r_prop_sum_a/$r_prop_rent ;
    

  7. Thank you everyone fo your help with this.

     

    I decided to use

     

    if ($number_field == "") {

    $number_field = $blank ;

    $number_field_plus = $blank ; }

     

    This makes both fields $0

     

    Thanks again everyone

     

    -Rob

     

    Not very good use of code tbh as $number_field may have a value, but $number_field_plus may not and will therefore remain blank. My code is the best.

  8. Not sure what is wrong but:

                 $filename="pages/" . $_GET['p'] . ".htm";
                if (file_exists($filename)){
                    include("pages/" . $_GET['p'] . ".htm");

    Is pointless excess code. Should be:

                 $filename="pages/" . $_GET['p'] . ".htm";
                if (file_exists($filename)){
                    include($filename);

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