Jump to content

ibz786

Members
  • Posts

    29
  • Joined

  • Last visited

Posts posted by ibz786

  1. Thanks litebearer and also cgeisler515 for your help thus far all your efforts are very appreciated

     

    litebearer, your code works thank you, just a one thing, why does it matter when php is:

    <?PHP and <?php

    I tried the code with <?php and i end up with errors however with <?PHP everything is fine

     

    Also cgeisler515, thanks for that, just how would i use an if statement in there?

     

    Thanks again

     

  2. Hmm i tried just using that current example and not even using my code, however it didn't work :(

     

    The thing is that what i need is:

    HA11QS, 200, house1.jpg, 4

    HA22BR, 280, house2.jpg, 10

    HA33AB, 390, house3.jpg, 3

    HA44CD, 320, house4.jpg, 8 in an array which i have done in the code provided in the first post

     

    However, when users are using a static web form:

    <form method="post" action="maxtest.php" >
    <input type="text" name="userprice" value="" />
    
    <input type="submit" name="button" value="Submit" />
    </form>

     

    They may type in e.g. 300 and the results:

    HA11QS, 200, house1.jpg, 4

    HA22BR, 280, house2.jpg, 10

     

    are returned to them :S

     

     

  3. Hi everyone,

     

    Basically i have a little task to do and was wondering if anyone is able to help, i would very grateful

     

    First task is for me to read a comma delimted file into PHP and store everything into an Array:

     

    Comma Delimited File = "houses.txt" (As a reference it means, PostCode, Price ('000's), picture and houses visits)

    HA11QS, 200, house1.jpg, 4

    HA22BR, 280, house2.jpg, 10

    HA33AB, 390, house3.jpg, 3

    HA44CD, 320, house4.jpg, 8

     

    my basic php for now is:

    <?php
    
    function getHouse ()
    {
    $filename = "houses.txt";
    $fileRead   = fopen($filename, "r");
    
    $rowsArr  = file ($filename);
    for ($i=0; $i < count($rowsArr); $i++)
    	{
    		$lineDetails = $rowsArr[$i];
    		print  $lineDetails . "<br>" ;
    	}
    
    	fclose($fileRead);
    }
    ?>
    
    <h3> Welcome </h3>
    
    <p> PostCode Number Picture Visits </p>
    
    <?php
    
    echo getHouse();
    
    ?>
    

     

    What i need to do next is to have a static web form where a user can input a maximum price e.g. 300

    And that will return all the houses which are under 300 by reading the whole array

     

    I have a basic form setup:

     

    <form method="post" action="maxtest.php" >
    <input type="text" name="userprice" value="" />
    
    <input type="submit" name="button" value="Submit" />
    </form>

     

    and also i have a an idea that i need something along the lines of:

    $userValue = $_POST['userprice'];
    
    	if ($userValue == 300)
    
    {
    }
    

     

    Im a bit stuck on how to incorporate the comma delimted array

     

    Please help me, thank you

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