PHP - Splitting File Data Into Strings To Populate Form
Hello
I am after some help with a concept to allow us to import some data into our database. I have a PDF which I have OCR'd and now have a word document... I then manually clean up the document to remove spurious characters, that part is fine. Now, the word document contains an unknown number of lines and an unknown number of records... and within those records an uknown number of fields... Here is an example of a single record: Mr G Aldred, 26/11/08, Canvardine Chance, Wolfies Dawn Tilley, KENINE SECRET DESTINY, d, c. Grey & White, KENINE SHADES OF THE NIGHT, d, c. Grey & White, KENINE SILENT WHISPER, b, c. Seal & White, KENINE SOFT KISSES, b, c. Grey & White, KENINE SPIRIT OF THE STORM, d, c. Seal & White KENINE STAR QUALITY, d, c. Seal & White And I could have multiple records like this, but with different number of names toward the end So, if I manually put some delimiting character instead of coma's , can I get PHP to read the WHOLE document in, split the document into records and then split those records into subfields to populate a form which I can then automatically submit to my database? Not sure if that is clear.... Thanks Similar TutorialsI have a form which creates a drop down list from data in a MySQL database. I would like to be able to have data from my database automatically populate based upon the selection from the list. How can I do that? Javascript? AJAX? Any help would be appreciated. Code: [Select] <?php $query2="SELECT tournament,id FROM 2011_Tournament"; $result2=mysql_query($query2); echo "<select name=2011_Tournament value='tournament'>Tournament</option>"; while($tournament=mysql_fetch_array($result2)){ echo "<option value='$tournament[tournament]'>$tournament[tournament]</option>"; } echo "</select>";?> Hello, I am trying to populate the value="" of my form with the data from the mysql database so users can see what is already completed, trial and error have failed me. what am i doing wrong? <?php session_start(); include 'english.php'; if (!isset($_SESSION['user'])) die("<br /><br />You need to login to view this page"); $user = $_SESSION['user']; echo "<h3>Edit your Profile Search</h3>"; //opend database $connect = mysql_connect("$dbhost","$dbuser","$dbpass"); mysql_select_db("$dbname"); //select database // Get all the data from the "housing" table $result = mysql_query("SELECT * FROM users WHERE user='$user'") or die(mysql_error()); // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) // Print out the contents of each row into a table ?> <form action="/includes/insert_profile.php" method="post"> <table border="0" cellspacing="0" cellpadding="3"> </td></tr> <tr><td>First Name:</td><td><input type="text" name="first" value="$first"> <tr><td>Middle Name:</td><td><input type="text" name="middle" value="$middle"> <tr><td>Last Name:</td><td><input type="text" name="last" value="$last"> <tr><td>Email:</td><td><input type="text" name="email" value="$email"> </td></tr> <tr><td>Date of Birth:</td><td> <select id="day" name="day" class="short"> <option value="1" selected="selected">1</option> <option value="2">2</option> <option value="3">3</option> </select> <select id="month" name="month" class="medium"> <option value="January" selected="selected">January</option> <option value="February">February</option> </select> <select id="year" name="year" class="medium"> <option value="2010" selected="selected">2010</option> <option value="2009">2009</option> <option value="2008">2008</option> </td></tr> <tr><td> <input type="Submit" value="Save"/> </td></tr> </table> </form> Hi, I am trying to split a string into an array and then seeing what sort of data it is. eg; I get the following string Quote api=somerandomkeyhere&user=someuser&password=somehashvaluehere&type=somethingelse I need to be able to put this into an array so in this case Code: [Select] myarray[type]=somethingelse myarray[api]=somerandomkeyhere myarray[user]=someuser myarray[password]=somehashvaluehere but it could include many more/less different value's separated by the & symbol. Thanks, -mme Basically I have a date of birth field (date) now how would I go about splitting that date field into 3 variables $year $month and $day? Any small push forward is much appreciated, I have searched but it seems that I might not be putting it into words correctly. Actually while writing this I suppose I might of thought of the solution Code: [Select] <?php $year = date('Y', strtotime($row['dob'])); $month = date('m', strtotime($row['dob'])); $day = date('d', strtotime($row['dob'])); ?> Would that be how you would go about it? Hi I have to submit an assignment where a user can upload a file of the type "Application/octet" and the script should be able to split this file into multiples files of smaller sizes and display a page where the user can download the split parts. Also the files are not to stay on the webserver after they are downloaded. Any recommendation or lead or even code pieces would be appreciated. Regards, GuddooSk. ok so say I have a file with .. this information in one file Code: [Select] 548402354 7e99c2c49be0ad1a95fd3b4a2f65fc941e9cf194 548402225 9e0b2788f21a317eb76159f3e0c4e4a090492f2a 548402329 1aa382935c94d73f58bdb3203686cc0124fb3443 548402596 c41655fa8f14346cbd8a656a18ecb82caa3c1f9c 548402535 558e1ee14f2423681668a168a3980304ac54bd15 548402456 48ee03332c417cab51eaec13b415fde8c0b6a641 548400202 5bf3400e3c074eb8b42a962dc7e60777d2b2848a 548400842 cc672d4785ec5b9e22db7b60e203286c840c4f37 548400682 547c8ac38243b0f9a94609177d0dd12194059aa5 548400810 54afebbb3e884fea5563c017b18dd390ff1ff034 548400581 ec7305326b5514cbf05ab4a78647ed756da9db55 548400431 b3dcaa272c759ebe4e5b00053ef390b21b23f60c and I want to take and split the contents into 6 different files.. So it would take the first 2 lines and write to filename 1.txt, then it would take the 2 lines after that and write a file named 2.txt, so on and so forth Any help is appreciated, thanks Hey everyone. I have some experience with PHP and can easily modify existing code, but seem to have trouble writing the logic from scratch. Situation: I'm using this Jquery slider ( http://mine.tuxfamily.org/?p=74#more-74 ) and would like to populate the slides with data coming from an XML file. The data will be text, images(URIs), and links to buy. The thing is, each slide will hold 4 items, and then I want to somehow using PHP logic, allow the code to generate the next slide... In other words, how would I code it so that after 4 entries, it creates a new slide? I'm imagining a For loop + SimpleXML functions... but just kind of fumbling in the dark here. Any direction or guidance is greatly appreciated! Kind regards, Dey Hello there.new member here in need of help! So i use the code the code below to display images from a folder into a form. My problem is that i put checkboxes with various selections in order to transfer the selected items later to a file or echo the submission. As it seems at the moment is that i can display correctly everything in my form but for some unknown reason i cannot echo/write to a txt file the files(names) that i choose with the checkbox.There seems to be something wrong with my loop but i'm not sure. I would appreciate any help.thank you in advance. Here is my code: <?php SESSION_START(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="author" content="vs" /> <meta name="robots" content="index, follow" /> <link rel="stylesheet" type="text/css" href="style.css" media="screen" /> <link rel="stylesheet" type="text/css" href="print.css" media="print" /> <link rel="stylesheet" href="lightbox.css" type="text/css" media="screen" /> <script type="text/javascript" src="js/prototype.js"></script> <script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script> <script type="text/javascript" src="js/lightbox.js"></script> <title></title> </head> <body> <div id="centerColumn"> <div id="header"> </div><!--//end #headern//--> <div id="navbar"> <ul> <li><a href="index.html" title="Home">Home</a></li> <li><a href="about.html" title="About us">About us</a></li> <li><a href="gallery.html" title="Gallery">Gallery</a></li> <li><a href="contact.html" title="Contact">Contact</a></li> </ul> </div><!--//end #nav//--> <?php echo '<h2 class="medium"><i>Hello '.$_SESSION['user'].'</i></h2>'; ?> <p><span class="small"></span><br /> This is your private directory. Please submit your selections and fill in the contact form, thank you. </p><br> <div align="center"> <form method="post" action="data2file.php"> <?php echo '<div STYLE="overflow: auto; width: 780px; height: 600px; border-left: 5px gray solid; border-bottom: 5px gray solid; border-top: 5px gray solid; border-right: 5px gray solid;; padding: 0px; margin: 0px";> <table border="1" cellspacing=0 cellpadding=1> <tr><td>'; $username = $_SESSION['user']; $url = $username."/"; $handle = opendir ($url); while (false !== ($file = readdir($handle))) { if($file != "." && $file != ".." && $file != basename(__FILE__)) { //echo '<table border=1><tr><td>'; echo '<a href="'.$url.$file.'" rel="lightbox"><img border=1 src="'.$url.$file.'"></a>'; echo '<br />'; echo "<input type=CHECKBOX name=$file>"; print $file; echo '<br>'; echo '<select name=color> <option>Select Color Format...</option> <option> Sepia </option> <option> Black & White </option> </select>'; echo '<br> <select name=size> <option>Select Size Format...</option> <option name=5x7> 5" x 7"(13x19 cm)</option> <option name=6x8> 6" x 8"(15x21 cm)</option> <option name=8x12> 8" x 12"(20x30 cm) </option> <option name=9x14> 9" x 14"(24x30 cm) </option> <option name=12x18> 12" x 18"(30x40 cm) </option> </select>'; echo '<br>Reprints <input type="text" name="reprints" size="1" value="0"><br />'; echo '<hr>'; //echo '</td></tr></table>'; } } echo '</td></div>'; echo ' <td valign="top"> <p>*First name, Last name, Country, Home Address, Postal code and email fields are required*</p> <input type="text" name="first" value="First Name" size="35"/><br> <input type="text" name="last" value="Last Name" size="35"/><br> <select name="country"> <option value=" " selected>(please select a country)</option> <option value="AF">Afghanistan</option> <option value="AL">Albania</option> <option value="DZ">Algeria</option> <option value="AS">American Samoa</option> <option value="AD">Andorra</option> <option value="AO">Angola</option> <option value="AI">Anguilla</option> <option value="AQ">Antarctica</option> <option value="AG">Antigua and Barbuda</option> <option value="AR">Argentina</option> <option value="AM">Armenia</option> <option value="AW">Aruba</option> <option value="AU">Australia</option> <option value="AT">Austria</option> <option value="AZ">Azerbaijan</option> <option value="BS">Bahamas</option> <option value="BH">Bahrain</option> <option value="BD">Bangladesh</option> <option value="BB">Barbados</option> <option value="BY">Belarus</option> <option value="BE">Belgium</option> <option value="BZ">Belize</option> <option value="BJ">Benin</option> <option value="BM">Bermuda</option> <option value="BT">Bhutan</option> <option value="BO">Bolivia</option> <option value="BA">Bosnia and Herzegowina</option>echo <option value="BW">Botswana</option> <option value="BV">Bouvet Island</option> <option value="BR">Brazil</option> <option value="IO">British Indian Ocean Territory</option> <option value="BN">Brunei Darussalam</option> <option value="BG">Bulgaria</option> <option value="BF">Burkina Faso</option> <option value="BI">Burundi</option> <option value="KH">Cambodia</option> <option value="CM">Cameroon</option> <option value="CA">Canada</option> <option value="CV">Cape Verde</option> <option value="KY">Cayman Islands</option> <option value="CF">Central African Republic</option> <option value="TD">Chad</option> <option value="CL">Chile</option> <option value="CN">China</option> <option value="CX">Christmas Island</option> <option value="CC">Cocos (Keeling) Islands</option> <option value="CO">Colombia</option> <option value="KM">Comoros</option> <option value="CG">Congo</option> <option value="CD">Congo, the Democratic Republic of the</option> <option value="CK">Cook Islands</option> <option value="CR">Costa Rica</option> <option value="CI">Cote dIvoire</option> <option value="HR">Croatia (Hrvatska)</option> <option value="CU">Cuba</option> <option value="CY">Cyprus</option> <option value="CZ">Czech Republic</option> <option value="DK">Denmark</option> <option value="DJ">Djibouti</option> <option value="DM">Dominica</option> <option value="DO">Dominican Republic</option> <option value="TP">East Timor</option> <option value="EC">Ecuador</option> <option value="EG">Egypt</option> <option value="SV">El Salvador</option> <option value="GQ">Equatorial Guinea</option> <option value="ER">Eritrea</option> <option value="EE">Estonia</option> <option value="ET">Ethiopia</option> <option value="FK">Falkland Islands (Malvinas)</option> <option value="FO">Faroe Islands</option> <option value="FJ">Fiji</option> <option value="FI">Finland</option> <option value="FR">France</option> <option value="FX">France, Metropolitan</option> <option value="GF">French Guiana</option> <option value="PF">French Polynesia</option> <option value="TF">French Southern Territories</option> <option value="GA">Gabon</option> <option value="GM">Gambia</option> <option value="GE">Georgia</option> <option value="DE">Germany</option> <option value="GH">Ghana</option> <option value="GI">Gibraltar</option> <option value="GR">Greece</option> <option value="GL">Greenland</option> <option value="GD">Grenada</option> <option value="GP">Guadeloupe</option> <option value="GU">Guam</option> <option value="GT">Guatemala</option> <option value="GN">Guinea</option> <option value="GW">Guinea-Bissau</option> <option value="GY">Guyana</option> <option value="HT">Haiti</option> <option value="HM">Heard and Mc Donald Islands</option> <option value="VA">Holy See (Vatican City State)</option> <option value="HN">Honduras</option> <option value="HK">Hong Kong</option> <option value="HU">Hungary</option> <option value="IS">Iceland</option> <option value="IN">India</option> <option value="ID">Indonesia</option> <option value="IR">Iran (Islamic Republic of)</option> <option value="IQ">Iraq</option> <option value="IE">Ireland</option> <option value="IL">Israel</option> <option value="IT">Italy</option> <option value="JM">Jamaica</option> <option value="JP">Japan</option> <option value="JO">Jordan</option> <option value="KZ">Kazakhstan</option> <option value="KE">Kenya</option> <option value="KI">Kiribati</option> <option value="KP">Korea, Democratic Peoples Republic of</option> <option value="KR">Korea, Republic of</option> <option value="KW">Kuwait</option> <option value="KG">Kyrgyzstan</option> <option value="LA">Lao Peoples Democratic Republic</option> <option value="LV">Latvia</option> <option value="LB">Lebanon</option> <option value="LS">Lesotho</option> <option value="LR">Liberia</option> <option value="LY">Libyan Arab Jamahiriya</option> <option value="LI">Liechtenstein</option> <option value="LT">Lithuania</option> <option value="LU">Luxembourg</option> <option value="MO">Macau</option> <option value="MK">Macedonia, The Former Yugoslav Republic of</option> <option value="MG">Madagascar</option> <option value="MW">Malawi</option> <option value="MY">Malaysia</option> <option value="MV">Maldives</option> <option value="ML">Mali</option> <option value="MT">Malta</option> <option value="MH">Marshall Islands</option> <option value="MQ">Martinique</option> <option value="MR">Mauritania</option> <option value="MU">Mauritius</option> <option value="YT">Mayotte</option> <option value="MX">Mexico</option> <option value="FM">Micronesia, Federated States of</option> <option value="MD">Moldova, Republic of</option> <option value="MC">Monaco</option> <option value="MN">Mongolia</option> <option value="MS">Montserrat</option> <option value="MA">Morocco</option> <option value="MZ">Mozambique</option> <option value="MM">Myanmar</option> <option value="NA">Namibia</option> <option value="NR">Nauru</option> <option value="NP">Nepal</option> <option value="NL">Netherlands</option> <option value="AN">Netherlands Antilles</option> <option value="NC">New Caledonia</option> <option value="NZ">New Zealand</option> <option value="NI">Nicaragua</option> <option value="NE">Niger</option> <option value="NG">Nigeria</option> <option value="NU">Niue</option> <option value="NF">Norfolk Island</option> <option value="MP">Northern Mariana Islands</option> <option value="NO">Norway</option> <option value="OM">Oman</option> <option value="PK">Pakistan</option> <option value="PW">Palau</option> <option value="PA">Panama</option> <option value="PG">Papua New Guinea</option> <option value="PY">Paraguay</option> <option value="PE">Peru</option> <option value="PH">Philippines</option> <option value="PN">Pitcairn</option> <option value="PL">Poland</option> <option value="PT">Portugal</option> <option value="PR">Puerto Rico</option> <option value="QA">Qatar</option> <option value="RE">Reunion</option> <option value="RO">Romania</option> <option value="RU">Russian Federation</option> <option value="RW">Rwanda</option> <option value="KN">Saint Kitts and Nevis</option> <option value="LC">Saint LUCIA</option> <option value="VC">Saint Vincent and the Grenadines</option> <option value="WS">Samoa</option> <option value="SM">San Marino</option> <option value="ST">Sao Tome and Principe</option> <option value="SA">Saudi Arabia</option> <option value="SN">Senegal</option> <option value="SC">Seychelles</option> <option value="SL">Sierra Leone</option> <option value="SG">Singapore</option> <option value="SK">Slovakia (Slovak Republic)</option> <option value="SI">Slovenia</option> <option value="SB">Solomon Islands</option> <option value="SO">Somalia</option> <option value="ZA">South Africa</option> <option value="GS">South Georgia and the South Sandwich Islands</option> <option value="ES">Spain</option> <option value="LK">Sri Lanka</option> <option value="SH">St. Helena</option> <option value="PM">St. Pierre and Miquelon</option> <option value="SD">Sudan</option> <option value="SR">Suriname</option> <option value="SJ">Svalbard and Jan Mayen Islands</option> <option value="SZ">Swaziland</option> <option value="SE">Sweden</option> <option value="CH">Switzerland</option> <option value="SY">Syrian Arab Republic</option> <option value="TW">Taiwan, Province of China</option> <option value="TJ">Tajikistan</option> <option value="TZ">Tanzania, United Republic of</option> <option value="TH">Thailand</option> <option value="TG">Togo</option> <option value="TK">Tokelau</option> <option value="TO">Tonga</option> <option value="TT">Trinidad and Tobago</option> <option value="TN">Tunisia</option> <option value="TR">Turkey</option> <option value="TM">Turkmenistan</option> <option value="TC">Turks and Caicos Islands</option> <option value="TV">Tuvalu</option> <option value="UG">Uganda</option> <option value="UA">Ukraine</option> <option value="AE">United Arab Emirates</option> <option value="GB">United Kingdom</option> <option value="US">United States</option> <option value="UM">United States Minor Outlying Islands</option> <option value="UY">Uruguay</option> <option value="UZ">Uzbekistan</option> <option value="VU">Vanuatu</option> <option value="VE">Venezuela</option> <option value="VN">Viet Nam</option> <option value="VG">Virgin Islands (British)</option> <option value="VI">Virgin Islands (U.S.)</option> <option value="WF">Wallis and Futuna Islands</option> <option value="EH">Western Sahara</option> <option value="YE">Yemen</option> <option value="YU">Yugoslavia</option> <option value="ZM">Zambia</option> <option value="ZW">Zimbabwe</option> </select> <input type="text" name="address" value="Home Address" size="45"> <input type="text" name="address" value="Postal Code" size="35" <input type="text" name="email" value="e-mail" size="35"/><br> <input type="text" name="date" value="Wedding Date (dd-mm-yyyy)" size="35"/><br> <input type="text" name="time" value="Wedding Time (hh:mm)"/><br> <input type="text" name="hotel" value="Hotel" size="35"/><br> <input type="text" name="room" value="Room Number" size="10"/><br> <hr> <TEXTAREA NAME="comments" ROWS=10 COLS=45 value="Comments">Notes / Comments </TEXTAREA><br> </td></tr> </table>'; echo '</div> <br> <input type="submit" name="submit" value="Submit"> <input type="reset" name="reset" value="Reset"> <a href="logout.php"><input type="button" name="logout" value="Logout"></form></a> </div> <br>'; ?> <div id="footer"> <a href="http://validator.w3.org/" title="W3C HTML Validation">XHTML</a> . <a href="http://jigsaw.w3.org/css-validator/validator-uri.html" title="W3C CSS Validation">CSS</a> . <a href="http://www.w3.org/TR/WCAG10/" title="Web Content Accessibility Guidelines">WCAG</a> . <a href="http://www.csstinderbox.com">The CSS Tinderbox</a></div> <div align="center" class="boxes"> <!--//end #footer//--><small> ©2009-2010</small></div> </div> <!--//end #centerColumn//--> <!--width=256 height=170--> </body> </html> and here is the process to file code: <?php SESSION_START(); $arxeio = "data.txt"; $fp = fopen($arxeio, "a") or die("Couldn't open $arxeio for writing!"); //fwrite($fp, $_POST[$file]."\n"); fwrite($fp, $_POST['color']."\n") or die("Couldn't write values to file!"); fwrite($fp, $_POST['size']."\n"); fclose($fp); echo $_SESSION['user']; echo $_POST['color']; echo $_POST['country']; echo "Saved to $arxeio successfully!"; ?> How should i make my code to work only for the selected items along with their attributes. Thank you very much. Ok, I have tried using the code from this link http://answers.yahoo.com/question/index?qid=20100927173625AAmEmiW Code: [Select] <?php // Get the name they entered in the form // We'll be naming the file this $file = $_POST['name']; // Get the email from the form $email = $_POST['email']; // We want the file to be a text file right? $ex = ".txt"; // Try to open a file named $file$ex (johndoe.txt for example) // Because this file doesn't exist yet the server creates it $write = fopen("$file$ex","w"); // Now open the file up again but this time save the email in it fwrite($write,$email); // MAKE SURE you close the file!!! fclose($write); // The folder that this script is in on the server is where the file we just made was saved // We can 'rename' it to another folder // The folder on the server we want to move it to $data = "../emails/"; // Now put it all together: This example goes out of the folder we're in and into the folder 'emails' // The new 'name' would be this now (../emails/johndoe.txt): So now the file is moved to where we want for storage rename ("$file","$data$file$ex"); // The script is done, send the user to another page (Just read the address below and you'll get it) exit; ?> unfortunately it doesn't do as i would like. I'm not sure how to get it to save a new file based on a variable on the form page or from one of the fields in the form. What i need is a way for a user to submit the form and it save the data into a uniquely named csv file. I know the code given is for text files, not csv, but that was about all i could find. If there is any help i would greatly appreciate it. Hi All,
I have a AmChart file, but unfortunately this data is static. I would like to make this data more dynamic by populating it from a PHP file. Please can someone direct me in doing this?
Here is the AmChart page Code:
<!DOCTYPE html> <html> <head> <title>Climate Survey Results</title> <!-- amCharts javascript sources --> <script type="text/javascript" src="http://cdn.amcharts.com/lib/3/amcharts.js"></script> <script type="text/javascript" src="http://cdn.amcharts.com/lib/3/serial.js"></script> <!-- amCharts javascript code --> <script type="text/javascript"> AmCharts.makeChart("chartdiv", { "type": "serial", "categoryField": "category", "angle": 45, "depth3D": 10, "startDuration": 0.5, "theme": "default", "categoryAxis": { "gridPosition": "start" }, "trendLines": [], "graphs": [ { "fillAlphas": 1, "fillColors": "#008000", "id": "very_satisfied", "lineColor": "#008000", "title": "Very Satisfied", "type": "column", "valueField": "Very Satisfied" }, { "fillAlphas": 1, "fillColors": "#0000FF", "id": "satisfied", "lineColor": "#0000FF", "title": "Satisfied", "type": "column", "valueField": "Satisfied" }, { "fillAlphas": 1, "fillColors": "#FF8000", "fontSize": 0, "id": "dissatisfied", "lineColor": "#FF8000", "title": "Dissatisfied", "type": "column", "valueField": "Dissatisfied" }, { "fillAlphas": 1, "fillColors": "#CC0000", "id": "very_dissatisfied", "lineColor": "#CC0000", "title": "Very Dissatisfied", "type": "column", "valueField": "Very Dissatisfied" } ], "guides": [], "valueAxes": [ { "id": "ValueAxis-1", "stackType": "100%", "title": "Percentage Scored (%)" } ], "allLabels": [], "balloon": {}, "legend": { "textClickEnabled": false, "useGraphSettings": false, "valueAlign": "centre" }, "titles": [ { "size": 20, "text": "Climate Survey Results" } ], "dataProvider": [ { "category": "1", "Very Satisfied": 4.69, "Satisfied": 65.63, "Dissatisfied": 23.43, "Very Dissatisfied": 6.25 }, { "category": "2", "Very Satisfied": 3.13, "Satisfied": 46.88, "Dissatisfied": 34.37, "Very Dissatisfied": 15.62 }, { "category": "3", "Very Satisfied": 1.56, "Satisfied": 56.25, "Dissatisfied": 32.81, "Very Dissatisfied": 9.38 }, { "category": "4", "Very Satisfied": 7.81, "Satisfied": 56.25, "Dissatisfied": 28.13, "Very Dissatisfied": 7.81 }, { "category": "5", "Very Satisfied": 7.81, "Satisfied": 35.94, "Dissatisfied": 43.75, "Very Dissatisfied": 12.5 }, { "category": "6", "Very Satisfied": 26.56, "Satisfied": 57.81, "Dissatisfied": 12.5, "Very Dissatisfied": 3.13 }, { "category": "7", "Very Satisfied": 10.94, "Satisfied": 43.75, "Dissatisfied": 28.13, "Very Dissatisfied": 17.19 }, { "category": "8", "Very Satisfied": 28.13, "Satisfied": 53.13, "Dissatisfied": 14.06, "Very Dissatisfied": 4.69 }, { "category": "9", "Very Satisfied": 26.56, "Satisfied": 64.06, "Dissatisfied": 7.81, "Very Dissatisfied": 1.56 }, { "category": "10", "Very Satisfied": 21.88, "Satisfied": 46.88, "Dissatisfied": 28.13, "Very Dissatisfied": 3.13 }, { "category": "11", "Very Satisfied": 1.56, "Satisfied": 43.75, "Dissatisfied": 45.31, "Very Dissatisfied": 9.38 }, { "category": "12", "Very Satisfied": 1.56, "Satisfied": 39.06, "Dissatisfied": 40.63, "Very Dissatisfied": 18.75 }, { "category": "13", "Very Satisfied": 3.13, "Satisfied": 43.75, "Dissatisfied": 31.25, "Very Dissatisfied": 21.87 }, { "category": "14", "Very Satisfied": 23.44, "Satisfied": 62.5, "Dissatisfied": 12.5, "Very Dissatisfied": 1.56 }, { "category": "15", "Very Satisfied": 9.38, "Satisfied": 53.12, "Dissatisfied": 35.94, "Very Dissatisfied": 1.56 } ] } ); </script> </head> <body> <div id="chartdiv" style="width: 50%; height: 400px; " ></div> </body> </html>My PHP returns the following: Array ( [0] => Array ( [Question] => 1. Overall how satisfied are you with your role / position at Altech Autopage? [Very Satisfied] => 4.6875 [Satisfied] => 65.6250 [Dissatified] => 23.4375 [Very Dissatisfied] => 6.2500 ) [1] => Array ( [Question] => 2. Employees are recognized as individuals. [Very Satisfied] => 3.1250 [Satisfied] => 46.8750 [Dissatified] => 34.3750 [Very Dissatisfied] => 15.6250 ) [2] => Array ( [Question] => 3. Employees are highly motivated to see the company succeed. [Very Satisfied] => 1.5625 [Satisfied] => 56.2500 [Dissatified] => 32.8125 [Very Dissatisfied] => 9.3750 ) [3] => Array ( [Question] => 4. Customer Operations clearly communicates its goals and strategies. [Very Satisfied] => 7.8125 [Satisfied] => 56.2500 [Dissatified] => 28.1250 [Very Dissatisfied] => 7.8125 ) [4] => Array ( [Question] => 5. Customer Operations offers clear opportunities for career advancement. [Very Satisfied] => 7.8125 [Satisfied] => 35.9375 [Dissatified] => 43.7500 [Very Dissatisfied] => 12.5000 ) [5] => Array ( [Question] => 6. My job responsibilities are clear. [Very Satisfied] => 26.5625 [Satisfied] => 57.8125 [Dissatified] => 12.5000 [Very Dissatisfied] => 3.1250 ) [6] => Array ( [Question] => 7. Management is sensitive to employee problems. [Very Satisfied] => 10.9375 [Satisfied] => 43.7500 [Dissatified] => 28.1250 [Very Dissatisfied] => 17.1875 ) [7] => Array ( [Question] => 8. My immediate supervisor provides a positive role model. [Very Satisfied] => 28.1250 [Satisfied] => 53.1250 [Dissatified] => 14.0625 [Very Dissatisfied] => 4.6875 ) [8] => Array ( [Question] => 9. Your own morale. [Very Satisfied] => 26.5625 [Satisfied] => 64.0625 [Dissatified] => 7.8125 [Very Dissatisfied] => 1.5625 ) [9] => Array ( [Question] => 10. The team spirit and level of cooperation among workers. [Very Satisfied] => 21.8750 [Satisfied] => 46.8750 [Dissatified] => 28.1250 [Very Dissatisfied] => 3.1250 ) [10] => Array ( [Question] => 11. The amount of recognition you receive for your work. [Very Satisfied] => 1.5625 [Satisfied] => 43.7500 [Dissatified] => 45.3125 [Very Dissatisfied] => 9.3750 ) [11] => Array ( [Question] => 12. The compensation you receive for your work. [Very Satisfied] => 1.5625 [Satisfied] => 39.0625 [Dissatified] => 40.6250 [Very Dissatisfied] => 18.7500 ) [12] => Array ( [Question] => 13. Your overall level of job security. [Very Satisfied] => 3.1250 [Satisfied] => 43.7500 [Dissatified] => 31.2500 [Very Dissatisfied] => 21.8750 ) [13] => Array ( [Question] => 14. The professionalism of your immediate supervisor. [Very Satisfied] => 23.4375 [Satisfied] => 62.5000 [Dissatified] => 12.5000 [Very Dissatisfied] => 1.5625 ) [14] => Array ( [Question] => 15. Overall, how would you rate Customer Operations as an area to work. [Very Satisfied] => 9.3750 [Satisfied] => 53.1250 [Dissatified] => 35.9375 [Very Dissatisfied] => 1.5625 ) ) Which is the same result as I am currently entering manually. Good day all.
I am trying to get strings from txt file with a start and an end.
$file = "/var/www/html/sataxicrm/custom/include/language/lang.en_us.lists.php"; $content = file_get_contents($file); $pos = strpos($content,"query_complaint_type_list"); $end = strpos($content,"status_0"); $string = substr($content,$pos,($end- $pos)); $array = nl2br($string); //print $content; echo "Database Value:Label Value <br>"; print $array;
The above code works well if you knowwhat your end string is, but in my case i do not know. i only know the start. As you can see i know it starts with account_type_dom but i do not know that it will end before industry_dom. so i need to stop before industry_dom. how do i do this? Quote
account_type_dom
Hi Everyone, I'm new to PHP freaks, and I'm hoping someone might be able to help me. I have written some code for a html page and used php to retrieve confirm whether or not data is in a text file. I also tried to write some code to insert the data supplied to my html page to the text file but it's not working. Can someone help me figure out what my issue is. I have attached my text file, and my php code as well. Below you'll find the code I used for my html page. Thank you for all your help, Phee <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Telephone Directory</title> </head> <body> <form action='SignGuestBook.php' method='post'> <h1>Sign Guest Book</h1> <hr> <br> <table align='Left'> <tr> <td>Name: </td> <td><input name='name' /></td> </tr> <tr> <td>E-mail: </td> <td><input name='email' /></td> </tr> <tr> <td><input type="submit" value='Sign' /></td> <td><input type="reset" value='Reset Form' /></td> </tr> </table> <h3></h3> <br> <h4></h4> <br> <h5></h5> <br> <h6></h6> <br> <h7></h7> <br> <hr> <a href="http://helios.ite.gmu.edu/~smohamu2/IT207/Lab%20Assignment%208/AddNew.html">View Guest Book</a> </form> </body> </html> [attachment deleted by admin] Hi! What i can't figure out, is how to delete between 2 given strings in another file. Explanation: I have a file, it contains following: Code: [Select] ### Start of content 0 ### Some Radom Lines with text 1 ### End of content 0 ### ### Start of content 1 ### Some Radom Lines with text 2 ### End of content 1 ### ### Start of content 2 ### Some Radom Lines with text 3 ### End of content 2 ### And so on, now i need code, which can find line i give and delete between. Something like this: If, i give string: Code: [Select] ### Start of content 0 ### Then it will delete this line to the Code: [Select] ### End of content 0 ### Hope you can help! All the best: Mart L. So here is my code: //form.html <form action="http://localhost/lab3/index.php" method="post " > <input type="text" name="numar" value=""><br> <input type="submit" name="submitButton" value="Submit"> </form> //and in index.php ,which is in the specified folder if I write : if($_POST['numar']!="") $m=$_POST['numar']; //then I get an error saying Undefined index: numar I really read a lot about forms and saw examples , but I can't figure out what's wrong. If you have any ideas.. how do I put a get id into this form, or use $myvar?: Code: [Select] <form action='read2.php?id=' method="post" name='myForm' id="myForm"></form> hi all,i have a php form that i would like to populate from a drop down list,my problem is that i cant place the drop down list at the correct place.what i want is that where the franchisee is the input should be the drop down,please help....this is the code that i am using Code: [Select] <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> <p>Add a Bus in the Bus table.</p> <p> Fleet Number:<br /> <input type="text" name="fleet_number" size="6" maxlength="10" value="" /> </p> <p> Registration Number:<br /> <input type="text" name="registration_number" size="10" maxlength="20" value="" /> </p> <p> Model:<br /> <input type="text" name="model" size="10" max length="15" value="" /> </p> <p> Franchisee :<br /> <input type="select" name="franchisee_id" size="10" max length="15" value="" /> <select name=dropdown_list> <?php while($row = oci_fetch_array($stid)) { echo "<option value='".$row['FRANCHISEE_NAME']."'>"; echo $row['FRANCHISEE_NAME']; echo "</option> "; } ?> </select> </p> <p> <input type="Submit" name="submit" value="Submit !" /> </p> </form> Hello forum,
So I've been developing an app mostly in PHP, but am rather afraid of JS. Hope to fix that.
I have an AJAX dropdown using JQuery to search locations. It works great. However, I want to make it similar to what is seen on this site:
http://placefinder.com/
As you can see, the dropdown, when clicked populates a box. Then the user submits the form and the data is used in the application.
I have no clue how to make the form populate with data from the DB (I'm using mySQL) when clicked. So far, I've only been able to make it clickable as a URL (not what I want, obvioiusly!)
Is there a way to do this on a really small, simple script for starters? I'm certain their is, but don't even know where to begin.
Any help appreciated
I am trying to work out how to correctly format an SQL query string from user data taken from multiple HTML text boxes/dropdowns. As an example assuming i have a searach page on which the user can enter search criteria into the following fields: name - text box site_location - drop down box (default set to 'search all') job_title - drop down box (default set to 'search all') manager - drop down box (default set to 'search all') email - textbox Its easy when all fields have user data set or one has user data set but when the user has entered data into only a couple of the fields I have problems constructing the SQL query, namely when it comes to adding the 'AND' keyword into the SQL query. No matter how i try to set out the logic in the PHP code i seem to end up with at least one combination of the search critea leading to back to back AND statements. I construct the SQL query by appending a string variable $query with the relevant search criteria, for example: $query = "select * from employees where "; if ($_POST['name'] != null) { $query=$query."name='".$_POST['name']."' "; } if ($_POST['site_location'] != 'all') { $query=$query."AND site_location='".$_POST['site_loaction']."' "; } //etc This does not work out though when fields are empty, I have tried adding additional if statements to check ahead to see if fields further down in the query are required and if so append an 'and' but I cannot seem to get the logic correct. Is this something anyone else has come accross, if so is there a better solution than the route i am going down? Thanks for reading. |