SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 40 of 40

Thread: Php

  1. #26
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <?php

    $columns = $_POST['columns'];
    for($i=1; $i<= $columns; $i++)
    {

    echo "Instance $i = "."<input type='text' size='2' name='r[]'>"." ";

    }
    echo"<br>Alocation Max Need Work";
    if (isset($_POST['submit'])) {

    // set variables from form input
    $rows = $_POST['rows'];
    $columns = $_POST['columns'];
    // loop to create rows
    for ($r = 1; $r <= $rows; $r++) {
    echo "<br>";
    // loop to create columns
    for ($c = 1; $c <= $columns;$c++) {
    echo "<input type='text' name='input[".$r."][".$c."]' size='5'> ";
    } echo "<br> ";
    }
    echo " ";
    }


    for ($r = 1; $r <= $rows; $r++) {
    echo "<br>";
    // loop to create columns
    for ($c = 1; $c <= $columns;$c++) {
    echo "<input type='text' name='max[".$r."][".$c."]' size='5'> ";
    } echo "<br> ";
    }
    ?>


    its running but the the Max is below the Allocated can we put it in the left side of the Allocated?

  2. #27
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    wrap it in table tags, 1 row 2 columns put the max entry in column 1, then the Allocated entry.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  3. #28
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by StarLion View Post
    wrap it in table tags, 1 row 2 columns put the max entry in column 1, then the Allocated entry.

    i got a problem about the the Table tagging when I tag the Max it goes in below the allocated can you find out the problem

    <?php
    echo"<table border = 5%>";
    $columns = $_POST['columns'];
    for($i=1; $i<= $columns; $i++)
    {

    echo "Instance $i = "."<input type='text' size='2' name='r[]'>"." ";

    }
    echo"<br>Alocation Max Need Work";
    if (isset($_POST['submit'])) {

    // set variables from form input
    $rows = $_POST['rows'];
    $columns = $_POST['columns'];
    // loop to create rows
    for ($r = 1; $r <= $rows; $r++) {

    // loop to create columns
    for ($c = 1; $c <= $columns;$c++) {
    echo "<td><input type='text' name='input[".$r."][".$c."]' size='5'> </td>";
    } echo "<tr>";
    }

    }


    for ($r = 1; $r <= $rows; $r++) {

    // loop to create columns
    for ($c = 1; $c <= $columns;$c++) {
    echo "<td><input type='text' name='max[".$r."][".$c."]' size='5'></td> ";
    } echo " <tr>";
    }
    echo"</table>";
    ?>

  4. #29
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    ...

    I'm going to ask a question, and I'm trying not to be offensive here.

    Do you know HTML?
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  5. #30
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by StarLion View Post
    ...

    I'm going to ask a question, and I'm trying not to be offensive here.

    Do you know HTML?


    Yeah I know a little

  6. #31
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    Why are you doing this assignment in the form of a webpage, if you only know html a little?
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  7. #32
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know HTML but not all..
    in our assignment it is just given to us and i dont know why she gives me this hard assignment
    i was just asking some of your help if you please i really got hard on the logic in this assignment but im trying my best to undserstand it..T_T

  8. #33
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    If you want the Max boxes to appear before the Allocated boxes... the code for Max will have to be before the code for Allocated.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  9. #34
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by StarLion View Post
    If you want the Max boxes to appear before the Allocated boxes... the code for Max will have to be before the code for Allocated.

    i got it now dude..
    about the needs function how can i obtain it??

  10. #35
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <?php
    echo"<table border = 5%>";
    $columns = $_POST['columns'];
    for($i=1; $i<= $columns; $i++)
    {

    echo "Instance R$i : "."<input type='text' size='2' name='r[]'>"." ";

    }

    if (isset($_POST['submit'])) {

    // set variables from form input
    $rows = $_POST['rows'];
    $columns = $_POST['columns'];



    echo"<br><br>ALLOCATION<br><br>";

    for($i=1; $i<= $columns; $i++) //loop for the Resource R1++
    {
    echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;R ".$i."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    }


    for ($r = 1; $r <= $rows; $r++) { // loop to create rows
    echo" <br>P ".$r;

    for ($c = 1; $c <= $columns;$c++) {// loop to create columns in Allocated

    echo "<input type='text' name='input[".$r."][".$c."]' size='5' > ";
    } echo "<br>";
    }

    }

    echo"<br>MAX<br>";
    for ($r = 1; $r <= $rows; $r++) {
    echo" <br>P ".$r;
    for ($c = 1; $c <= $columns;$c++) {// loop to create columns in Max

    echo "<input type='text' name='max[".$r."][".$c."]' size='5'> ";
    } echo "<br>";
    }

    ?>


    thanks for the help
    this is my current PHP code now its kinda good now..
    can you help me how to do the Need And Work..

  11. #36
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i have a problem in PHP banker's to , and my problem is , is about getting the value from the table that you created ,
    for ($r = 1; $r <= $rows; $r++) {
    echo "<br>";
    // loop to create columns
    for ($c = 1; $c <= $columns;$c++) {
    echo "<input type='text' name='input[".$r."][".$c."]' size='5'> ";
    } echo "<br> ";
    }

    How can i get the value from the " input[".$r."][".$c."] " i'm confuse , how can you say that is an array ,
    when you do not declare array at the top
    for example:

    $allocation = array('r'=> array(),
    'c'=> array());

    that actually a two dimentional array, my real question is, how can you implement the two dimenstional array ? and
    how can i get the value that they inputed from the table matrix that i show above from you example ??

  12. #37
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sir StarLion , please give us the php code how can we display the obtain input from Allocation and Need , i am having a hard time
    in getting there input in the table that they inputed from
    Quote Originally Posted by hanzodarkria View Post
    for ($r = 1; $r <= $rows; $r++) {
    // loop to create columns in Allocated
    for ($c = 1; $c <= $columns;$c++) {
    echo "<td><input type='text' name='input[".$r."][".$c."]' size='5' > </td>";
    } echo "";
    }
    sir StarLion , please help me .

    Quote Originally Posted by hanzodarkria View Post
    <html>
    <head></head>
    <body>
    <form method="post" action="OS.php">
    Enter number of rows <input name="rows" type="text" size="4">
    and columns <input name="columns" type="text" size="4">
    <input type="submit" name="submit" value="Draw Table">
    </form>

    <?php
    echo"<table border = 5%>";
    $columns = $_POST['columns'];
    for($i=1; $i<= $columns; $i++)
    {

    echo "Instance $i = "."<input type='text' size='2' name='r[]'>"." ";

    }
    echo"<br>Alocation Max Need Work";
    if (isset($_POST['submit'])) {

    // set variables from form input
    $rows = $_POST['rows'];
    $columns = $_POST['columns'];
    // loop to create rows

    for ($r = 1; $r <= $rows; $r++) {

    // loop to create columns in Allocated
    for ($c = 1; $c <= $columns;$c++) {
    echo "<td><input type='text' name='input[".$r."][".$c."]' size='5' > </td>";
    } echo "";
    }

    }


    for ($r = 1; $r <= $rows; $r++) {

    // loop to create columns in Max
    for ($c = 1; $c <= $columns;$c++) {
    echo "<td><input type='text' name='max[".$r."][".$c."]' size='5'></td> ";
    } echo "";
    }
    echo"</table>";
    ?>
    <br>
    <br><input type="submit" name="submit" value="Submit">
    <input type="reset" name="Reset">
    </body>
    </html>

  13. #38
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by StarLion View Post
    Real quick like:
    Code:
    <?php
    
    $columns = $_POST['columns'];
    for($i=1; $i<= $columns; $i++)
    {
    
    echo "Instance $i = "."<input type='text' size='2' name='r[]'>"." ";
    
    }
    echo"<br>Alocation Max Need Work";
    if (isset($_POST['submit'])) {
    
    // set variables from form input
    $rows = $_POST['rows'];
    $columns = $_POST['columns'];
    // loop to create rows
    for ($r = 1; $r <= $rows; $r++) {
    echo "<br>";
    // loop to create columns
    for ($c = 1; $c <= $columns;$c++) {
    echo "<input type='text' name='input[".$r."][".$c."]' size='5'> ";
    } echo "<br> ";
    }
    echo " ";
    }
    ?>
    The green section creates your ResourceMax section.
    The red section creates -1- of your inputs (lets say Allocation, because that came first in the list). Copy and paste the red code again below it, change 'input' to something else, say 'max'. Now you've got spaces for your Allocated, and your Max. Need and Available dont need to be filled in by the user because they are calculated, so dont display anything for those.
    Sir StarLion , how can we get the input value of the user from the table , i am really having a hard time , in getting the value of the table which the user inputed .
    Sir, StarLion , can you give us a code which get's the value of the table which the user inputed then display it !! please help me.

  14. #39
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is also a Banker's algorithm problem
    Sir StarLion , how can we get the input value of the user from the table , i am really having a hard time , in getting the value of the table which the user inputed in the table
    for ($r = 1; $r <= $rows; $r++) {
    echo "<br>";
    // loop to create columns
    for ($c = 1; $c <= $columns;$c++) {
    echo "<input type='text' name='input[".$r."][".$c."]' size='5'> ";
    } echo "<br> ";
    }
    Sir, StarLion , can you give us a code which get's the value of the table which the user inputed and display it !!
    or either display the Need which result from "MAX - Allocation". please help me , its badly needed !!

  15. #40
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    First of all, 'how i can say it is an array', is that at this point of echoing it out, it's an HTML Input array, not a PHP array.

    When you get to the parsing stage (after the user pushes the "Submit" button), this array would be referenced in a double-nested loop of values $r and $c by: $_POST['input'][$r][$c]
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •