Jump to content

devouk

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Everything posted by devouk

  1. hi I been working on a little snippet of code <about the level of my skill> The idea i trying to work out is I have a text file which i open, it has the heading id,image,link,desc and the value are separated by commas, I then load them in to a multi dimension array Create a random number and select the appropriate id in the array, then do this again and make sure that they are not the same, if that is ok then load the results of each element in to variable so i can then manipulate in my code I been playing with bits of code and so far got this <?php // the HTML source of a URL. $lines = file('textfile.txt'); //total lines available $limit = count($lines); //get the keys/headers $headers = explode(",",$lines[0]); //to store the data $ListItems = array(); // Loop through array to extract data for($i=1; $i < $limit; ++$i) { //extract the values $values = explode(",",$lines[$i]); //create temporary array $temp = array(); //store the values for( $j=0, $inner_limit=count($values); $j < $inner_limit; ++$j) { $temp[ $headers[$j] ] = $values[$j]; } //append to "master array" $ListItems[]=$temp; } // count how many rows are in the ray $NoListElements=count($ListItems)-1; echo "Elements " .$NoListElements. "<br />"; //reset random nos $randomID1=0; $randomID2=0; // get random number 1 $randomID1 = mt_rand(1,$NoListElements); // testing to ensure get 2nd random number which is not the same while($randomID2 == 0) { $randomID2 = mt_rand(1,$NoListElements); if ($randomID2 == $randomID1) $randomID2 = 0 ; } // Display values echo "Random 1 =" .$randomID1; echo "<br/>"; echo "Random 2 =" .$randomID2; echo "<br/>"; //Need to get the row element for random id 1 from ListItems <help needed here> //Need to get the row element for random id 2 from ListItems <help needed here> but i not too sure how to get any further if you can explain how i would put these in to a variable and also how if i can just access them direct to put in to my html code .. ie echo i presume !!! thanks for the missing links
  2. thanks darkwater.. you pointer me in the right direction and then played with what you gave and refined it to the point where i need to do a bit of error checking... it seems so easy what i did <?php $name=$post['name']; ?> <form method="post" action="processed.php"> <p>Name<input name="name" value="<?php print($name) ?>" type="text" class="formstyle" size="25" maxlength="50" style="width: 160px;" /> <br/> </form> I am greatefull for you bearing with me for a php fixer rather than programmer. !
  3. Hi Darkwater Thanks for the fast reply.. yeah i know basic php.. and i understand that the "post" send its an array .. but it was how i take the items from the array and push them from a variable back in to the form elements of textboxes off the new form.. without compromising the form if accessed without the post parameters can you tell me the best way of doing this ? Thanks
  4. Hi all Looking for a bit advice on the following The original idea was a demo site that was created for us on a new look website, but the company seems a bit reluctant to put in to a cms and also do the changes.. but one thing they have done which demistifises me and any google searching i been doing the following days Basically they have a "start an enquiry" form on each page. The form has name, phone, product query, and area This then is posted via a "post" to an enquiry.php page which is a full form and the values are populated with new extra fields and a captucha. I looked at the html and the javascript and there is nothing there so i presume they have done it with php. Now the enquiry page is its own entity .. ie no values passed and thus all fields are empty ie value="" i even tried to see if i "start an enquiry" if it echo the code thus i would be able to see this in the html which it doesnt. can someone point me in the direction of how to do this. is it done with php and dom which i havent really got a clue http://www.crearesites.co.uk/bradrail I find this a usefull feature but seems rarely discussed and wish to be enlightened. Many thanks
×
×
  • 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.