elementary str_pad question

Discussion in 'PHP' started by jacka, Apr 4, 2007.

  1. #1
    Hi

    I have looked at the manula for above code but for the life of me can't figure out why it doesn't do what i should.
    I am trying to input name of a field, - , first time round; -- (2nd time round), ---(3rd time round ) etc. etc.





    <?php
    $x=1;
    $str = "-";
    while ($row = mysql_fetch_array($result))
    {

    ?>
    <input type="hidden" size="30" name="Qty<?php echo".$x";?>" value="<?php

    echo $row["qty"];

    ?>" >


    <input type="hidden" size="30" name="Part Number<?php echo".$x";?>" value="<?php

    echo $row["part_number"];


    ?>" >



    <input type="hidden" size="30" name="Price Each<?php echo".$x";?>" value="<?php

    echo "£".$row["price_each"];



    ?>" >


    <input type="hidden" size="30" name="<?php



    echo str_pad($str,$x,'-');



    ?>" value =" 222">

    <?php
    echo str_pad($str, $x, '-', STR_PAD_RIGHT);

    echo $x;
    $x=$x+1;

    }
    ?>

    p.s I am very new to php.
    thanking you in advance
     
    jacka, Apr 4, 2007 IP