Jump to content

nevsi79

Members
  • Posts

    23
  • Joined

  • Last visited

    Never

Everything posted by nevsi79

  1. maybe use explode have a look at the php site here: http://uk3.php.net/explode hope that helps
  2. thank you, but no, it came up with a php syntax error for this line when i replaced it :-\
  3. Hey guys, I've got this script: $fieldset = $_POST['tfa_Item']; $field = $_POST['tfa_ItemName']; print_r($field); echo"<br/>"; $field1 = $_POST['tfa_ItemMake']; print_r($field1); echo"<br/>"; $field2 =$_POST['tfa_ItemDetails']; print_r($field2); echo"<br/>"; $field3 =$_POST['tfa_ItemPrice']; print_r($field3); echo"<br/>"; $q1 = "INSERT INTO items_claimed (master_id) VALUES ('$master_id')"; for ($i = 0; $i < count($field); $i++) $qSet[] = '(\'' . $field[$i] . '\', \'' . $field2[$i] . '\', \'' . $field2[$i] . '\', \'' . $field3[$i] . '\')'; $q = 'INSERT INTO items_claimed (`item_name`, `item_make`, `item_details`, `item_price`) VALUES ' . implode(', ', $qSet); if (!mysql_query($q) ) echo 'could not add!<br>' . mysql_error(); which is doing a great job - inserting an array in mySql db table: However I now want to connect tables and I am using: $master_id = mysql_insert_id($connect); So far so good but when I change the query to: $q = 'INSERT INTO items_claimed (`master_id`, `item_name`, `item_make`, `item_details`, `item_price`) VALUES ' . $master_id .' , ' . implode(', ', $qSet); where 84 is the master id, ('desk', 'oak', 'oak', '789') - is my first array and ('notebook', 'nice', 'nice', '') - my second array within the multidimensional array. Any help will be greatly appreciated!
  4. MAGIC!!!!!! SORTED! You're a life saver! Thank you so much!
  5. Hey guys, I've got the following arrays: how can I put them in mySql db table which basically has the following columns: first name, last name and DOB, I want A (first name A, last name A, DOB A) to be one entry (row) in my table and correspondingly (first name B, last name B, DOB B) next entry (row) and (first name C, last name C, DOB C) another entry (row) Please can anyone help?????
  6. no it didn't work with print_r($fieldset) it did work with my foreach earlier I was so happy, jumping on my bed with joy and then I messed it up, can't even see why
  7. so it must be a multidimensional array? is it sth like: $chars = array( array( "name" => "Bob", "age" => "20" ), array( "name" => "Jane", "age" => "27" ); the output will be: echo $chars[0][age] - this should give you: 20 now to loop through a multidimensional arrays like this use: foreach ($chars as $c) { while(list($k, $v) = each ($c)) { echo "k ... $v <br/>"; } } Hope this helps
  8. Yes but it worked the first time, I found this in my book: foreach ($fieldset as $c) { while(list($k, $v) = each ($c)) { echo "k ... $v <br/>"; } } Anyhow, you might understand me better if I do the following (print_r the fields as they are arrays even if I do not repeat them with the repeat js behaviour as I added [] to the names of each field): <?php $cnt = count($_POST['wf_Relatives1']); // any field that //repeats(if you want to know how many repeats there are) $fieldset = $_POST['wf_Relatives1']; $field = $_POST['wf_FirstName']; print_r($field); echo"<br/>"; $field2 =$_POST['wf_LastName']; print_r($field2); echo"<br/>"; $field3 =$_POST['wf_BirthDate2']; print_r($field3); echo"<br/>"; //foreach ($fieldset as $c) { //while(list($k, $v) = each ($c)) { //echo "k ... $v <br/>"; //} //} ?> and then I get this output: I do not insist in organising them in a multidimensional array, but my final go is t put them in mysql table. MySql table will basically have 3 columns: first name, last name, DOB and I want A, B & C to be different entries i.e. rows in my table, if that makes sense at all? Can anyone help, please?
  9. my script worked, i was jumping on my bed with joy, then I modified and now it does not work I just can't see why?!!! here's my form: http://geeks-fix.co.uk/wforms/form.html now this is my code: <?php $cnt = count($_POST['wf_Relatives1']); // any field that //repeats(if you want to know how many repeats there are) $fieldset = $_POST['wf_Relatives1']; $field = $_POST['wf_FirstName']; //echo "$field"; $field2 =$_POST['wf_LastName']; //echo "$field"; $field3 =$_POST['wf_BirthDate2']; //echo "$field"; foreach ($fieldset as $c) { while (list($k, $v) = ($c)) { echo "$k ... $v <br/>"; } } ?> The first time it worked definitely with the $fieldset and after I added 3 times (first name, last name, dob) in the form, it did output the following: 0 ... some first name A 1 ... some first name B 2 ... some first name C 0 ... some last name A 1 ... some last name B 2 ... some last name C 0 ... some dob A 1 ... some dob B 2 ... some dob C but now it is not working, instead prints out this: Can anyone see where the problem is: I wonder how they are doing it here: http://www.formassembly.com/wForms/v2.0/documentation/examples/repeat.html
  10. thank you! I changed the code to: <?php $max = (int) $_POST["wf_Relatives1-RC"]; for($i=1;$i<=$max;$i++) { if($i==1) { $repeatclass = "repeat"; $rowIndex = ""; } else { $repeatclass = "removeable"; $rowIndex = "-".$i; } if(isset($_POST["wf_FirstName".$rowIndex]) && isset($_POST["wf_LastName".$rowIndex]) && isset($_POST["wf_LastName".$rowIndex])) { // account for sequence gap. ?> <fieldset id="wf_Relatives1<?php echo($rowIndex); ?>" class="<?php echo($repeatclass); ?>"> <label for="wf_FirstName<?php echo($rowIndex); ?>">Label 1: </label> <input type="text" id="wf_FirstName<?php echo($rowIndex); ?>" name="wf_FirstName<?php echo($rowIndex); ?>" value="<?php echo($_POST["wf_FirstName".$rowIndex]); ?>" /> <label for="wf_LastName<?php echo($rowIndex); ?>">Label 2: </label> <input type="text" id="wf_LastName<?php echo($rowIndex); ?>" name="wf_LastName<?php echo($rowIndex); ?>" value="<?php echo($_POST["wf_LastName".$rowIndex]); ?>" /> </fieldset> <?php } } //echo"<input type=\"hidden\" name=\"wf_Relatives1-RC\" id=\"wf_Relatives1-RC\" value="'.$max.'"/>"; echo"<input type='hidden' name='wf_Relatives1-RC' id='wf_Relatives1-RC' value='".$max."'/>"; ?> and now it works! However can anyone help me, show me/ tell me how to put this: <fieldset id="wf_Relatives1<?php echo($rowIndex); ?>" class="<?php echo($repeatclass); ?>"> <label for="wf_FirstName<?php echo($rowIndex); ?>">Label 1: </label> <input type="text" id="wf_FirstName<?php echo($rowIndex); ?>" name="wf_FirstName<?php echo($rowIndex); ?>" value="<?php echo($_POST["wf_FirstName".$rowIndex]); ?>" /> <label for="wf_LastName<?php echo($rowIndex); ?>">Label 2: </label> <input type="text" id="wf_LastName<?php echo($rowIndex); ?>" name="wf_LastName<?php echo($rowIndex); ?>" value="<?php echo($_POST["wf_LastName".$rowIndex]); ?>" /> </fieldset> in an array, check whether it is an array and then print the array? ??? I am really afraid of multidimensional arrays
  11. Hey guys, I've got this script: <?php $max = (int) $_POST["wf_Relatives1-RC"]; for($i=1;$i<=$max;$i++) { if($i==1) { $repeatclass = "repeat"; $rowIndex = ""; } else { $repeatclass = "removeable"; $rowIndex = "-".$i; } if(isset($_POST["wf_FirstName".$rowIndex]) && isset($_POST["wf_LastName".$rowIndex]) && isset($_POST["wf_LastName".$rowIndex])) { // account for sequence gap. ?> <fieldset id="wf_Relatives1<?php echo($rowIndex)?>" class="<?php echo($repeatclass)?>"> <label for="wf_FirstName<?php echo($rowIndex)?>">Label 1: </label> <input type="text" id="wf_FirstName<?php echo($rowIndex)?>" name="wf_FirstName<?php echo($rowIndex)?>" value="<?php echo($_POST["wf_FirstName".$rowIndex])?>" /> <label for="wf_LastName<?php echo($rowIndex)?>">Label 2: </label> <input type="text" id="wf_LastName<?php echo($rowIndex)?>" name="wf_LastName<?php echo($rowIndex)?>" value="<?php echo($_POST["wf_LastName".$rowIndex])?>" /> </fieldset> <?php } } echo"<input type="hidden" name="wf_Relatives1-RC" id="wf_Relatives1-RC" value="'.$max.'"/>"; //this is line 26 ?> when I run it I get this error: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' I've commented in the script where line 26 is. Can anyone help, please?
  12. thank you for your post but still the same
  13. This is the form, but so far I have only output <h3>Claim Details</h3>. Hopefully you will not be confused with the rest of it. <!-- FORM: HEAD SECTION --> <link href="http://app.formassembly.com/wForms/3.0/css/black/wforms.css" rel="stylesheet" type="text/css"></link> <link href="http://app.formassembly.com/wForms/3.0/css/wforms-jsonly.css" rel="alternate stylesheet" title="This stylesheet activated by javascript" type="text/css"></link> <link href="http://app.formassembly.com/wForms/3.0/css/wforms-layout.css" rel="stylesheet" type="text/css"></link> <link href="file:///nevenaaleksieva/Desktop/testform.css" rel="stylesheet" type="text/css" /> <!--[if IE 7]> <link href="http://app.formassembly.com/wForms/3.0/css/wforms-layout-ie7.css" rel="stylesheet" type="text/css"></link> <![endif]--> <script type="text/javascript" src="http://app.formassembly.com/wForms/3.0/js/wforms.js"></script> <script type="text/javascript" src="http://app.formassembly.com/wForms/3.0/js/wforms_custom_validation.js"></script> <script type="text/javascript" src="http://app.formassembly.com/js/populate_form.js"></script> <!-- FORM: BODY SECTION --> <div class="wForm"> <div class="codesection" id="code-"></div> <form method="post" action="http://www.geeks-fix.co.uk/testform/output.php" id="id2489978" class="labelsAbove hintsTooltip" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="10485760"><div class="wfPage " id="wfPgIndex-1"> <h3>Claim Details:</h3> <div class="oneField"> <label for="tfa_YourRefNo" class="preField">Your Ref. No:<span class="reqMark">*</span></label> <input type="text" id="tfa_YourRefNo" name="tfa_YourRefNo" value="" size="40" class="required"><br> <span class="errMsg" id="tfa_YourRefNo-E"></span> </div> </div> <div class="wfPage " id="wfPgIndex-2"> <h3>Policy Holder Info</h3> <fieldset id="tfa_FullName" class=""> <legend>Full Name</legend> <div class="oneField"> <label for="tfa_Title" class="preField">Title</label> <input type="text" id="tfa_Title" name="tfa_Title" value="" size="8" class=""><br> <span class="errMsg" id="tfa_Title-E"></span> </div> <div class="oneField"> <label for="tfa_FirstName" class="preField">First Name</label> <input type="text" id="tfa_FirstName" name="tfa_FirstName" value="" size="50" class=""><br> <span class="errMsg" id="tfa_FirstName-E"></span> </div> <div class="oneField"> <label for="tfa_Initials" class="preField">Initials</label> <input type="text" id="tfa_Initials" name="tfa_Initials" value="" size="" class=""><br> <span class="errMsg" id="Initials-E"></span> </div> <div class="oneField"> <label for="tfa_FamilyName" class="preField">Family Name<span class="reqMark">*</span></label> <input type="text" id="tfa_FamilyName" name="tfa_FamilyName" value="" size="50" class="required"> <div class="field-hint-inactive" id="tfa_FamilyName-H"> <span>if there is more than one person on the policy, please separate the family names with comma.</span> </div> <br><span class="errMsg" id="tfa_FamilyName-E"></span> </div> </fieldset> <fieldset id="tfa_Address" class=""> <legend>Address</legend> <div class="oneField"> <label for="tfa_StreetAddress" class="preField">Street Address<span class="reqMark">*</span></label> <input type="text" id="tfa_StreetAddress" name="tfa_StreetAddress" value="" size="50" class="required"><br> <span class="errMsg" id="tfa_StreetAddress-E"></span> </div> <div class="oneField"> <label for="tfa_Addresscontinued" class="preField">Address continued</label> <input type="text" id="tfa_Addresscontinued" name="tfa_Addresscontinued" value="" size="50" class=""><br> <span class="errMsg" id="tfa_Addresscontinued-E"></span> </div> <div class="oneField"> <label for="tfa_City" class="preField">City</label> <input type="text" id="tfa_City" name="tfa_City" value="" size="" class=""><br> <span class="errMsg" id="tfa_City1-E"></span> </div> <div class="oneField"> <label for="tfa_Postcode" class="preField">Postcode<span class="reqMark">*</span></label> <input type="text" id="tfa_Postcode" name="tfa_Postcode" value="" size="8" class="required"> <br><span class="errMsg" id="tfa_Postcode-E"></span> </div> </fieldset> <fieldset id="tfa_Telephone" class="required"> <legend>Telephone:</legend> <div class="oneField"> <label for="tfa_Home" class="preField">Home:</label> <input type="text" id="tfa_Home" name="tfa_Home" value="" size="40" class="validate-integer"> <br><span class="errMsg" id="tfa_Home-E"></span> </div> <div class="oneField"> <label for="tfa_Mobile" class="preField">Mobile:</label> <input type="text" id="tfa_Mobile" name="tfa_Mobile" value="" size="40" class="validate-integer"> <br><span class="errMsg" id="tfa_Mobile-E"></span> </div> <div class="oneField"> <label for="tfa_Work" class="preField">Work:</label> <input type="text" id="tfa_Work" name="tfa_Work" value="" size="40" class="validate-integer"><br> <span class="errMsg" id="tfa_Work-E"></span> </div> </fieldset> <div class="oneField"> <label for="tfa_emailaddress" class="preField">email address</label> <input type="text" id="tfa_emailaddress" name="tfa_emailaddress" value="" size="40" class="validate-email"> <br> <span class="errMsg" id="tfa_emailaddress-E"></span> </div> </div> <div class="wfPage " id="wfPgIndex-3"> <h3>Item Claimed Details:</h3> <fieldset id="tfa_Item" class="repeat"> <legend>Item </legend> <div class="oneField"> <label for="tfa_ItemName" class="preField">Item Name<span class="reqMark">*</span></label> <input type="text" id="tfa_ItemName" name="tfa_ItemName" value="" size="40" class="required"><br> <span class="errMsg" id="tfa_ItemName-E"></span> </div> <div class="oneField"> <label for="tfa_ItemMake" class="preField">Item Make</label> <input type="text" id="tfa_ItemMake" name="tfa_ItemMake" value="" size="40" class=""> <br><span class="errMsg" id="tfa_ItemMake-E"></span> </div> <div class="oneField"> <label for="tfa_ItemDetails" class="preField">Item Details</label> <input type="text" id="tfa_ItemDetails" name="tfa_ItemDetails" value="" size="40" class=""><br> <span class="errMsg" id="tfa_ItemDetails-E"></span> </div> <div class="oneField"> <label for="tfa_ItemPrice" class="preField">Item Price</label> <input type="text" id="tfa_ItemPrice" name="tfa_ItemPrice" value="" size="40" class=""><br> <span class="errMsg" id="tfa_ItemPrice-E"></span> </div> <span class="duplicateSpan"><a id="tfa_Item-wfDL" class="duplicateLink" href="#">add another item</a> </span> </fieldset> <div class="oneField"> <label for="tfa_Attachadditional" class="preField">Attach additional info</label> <input type="file" id="tfa_Attachadditional" name="tfa_Attachadditional" value="" size="40" class=""><br> <span class="errMsg" id="tfa_Attachadditional-E"></span> </div> </div> <div class="actions"> <input type="submit" class="primaryAction" id="submit-" name="tfa_submitAction" value="SUBMIT"> <input type="button" class="secondaryAction" onclick="history.go(-1)" value="CANCEL"> <input type="hidden" value="12461" name="tfa_dbFormId" id="tfa_dbFormId"> <input type="hidden" value="" name="tfa_dbResponseId" id="tfa_dbResponseId"> <input type="hidden" value="f7d9626afc92956c65cb904d2a6abcb7" name="tfa_dbControl" id="tfa_dbControl"> </div> </form> </div>
  14. it returned blank
  15. sorry I do not understand your question This is all my code: session_start(); include('conn.php');//Connection to databse //Random Number $rand = rand(1000, 2000); $_SESSION['guid'] = $rand; $guid = $_SESSION['guid']; echo "SESSION ID is <b>".$guid."</b><br/><br/>"; $your_ref_no = htmlspecialchars($_POST['tfa_YourRefNo']); //check to see if the form has been submitted if(isset($_POST['tfa_submitAction'])){ //add to claim_details table $add_claim_details_sql = "INSERT INTO claim_details (ins_ref_no) VALUES ('$your_ref_no')"; $add_claim_details_res = mysql_query($add_claim_details_sql) or die ("Could not edit item details:" . mysql_error()); echo $add_claim_details_res; echo "</br>"; echo "thank you, your form has been submitted and the your data was stored in our db"; echo "</br>"; $query = "SELECT id FROM claim_details WHERE id='".mysql_real_escape_string($_GET['id'])."'"; $result = mysql_query($query)or die("Could not get your ref. no.:" . mysql_error()); //$row = mysql_fetch_array($result); $num_rows = mysql_num_rows($result); echo $num_rows; My form is in another file called: testform.html The testform.html has an action that equals the url to the above php page and the submit button of the testform.html has a name=''tfa_submitAction''.
  16. I think I am not targeting the id properly, is $_GET['id'] the right variable ???? I tried the following: $num_rows = mysql_num_rows($result); echo $num_rows; and it returned 0?????
  17. thank you thorpe, Embarrassed - as I said I am new to PHP Embarrassed so I added the following 2 lines to my script: Code: $row = mysql_fetch_array($result); echo $row; but it did not return the id, it returned nothing! What am I doing wrong?
  18. thank you thorpe, - as I said I am new to PHP so I added the following 2 lines to my script: $row = mysql_fetch_array($result); echo $row; but it did not return the id, it returned nothing! What am I doing wrong?
  19. It didn't work guys as I don't get the ref. no (i.e. the id unique to the just submitted data), instead I get: Here is all my code: $add_claim_details_sql = "INSERT INTO claim_details (ins_ref_no) VALUES ('$your_ref_no')"; $add_claim_details_res = mysql_query($add_claim_details_sql) or die ("Could not edit item details:" . mysql_error()); echo $add_claim_details_res; echo "</br>"; echo "thank you, your form has been submitted and the your data was stored in our db"; echo "</br>"; $query = "SELECT id FROM claim_details WHERE id='".mysql_real_escape_string($_GET['id'])."'"; $result = mysql_query($query)or die("Could not get your ref. no.:" . mysql_error()); echo "your ref no is: $result"; When I run it, I get the following every time: Where 1 is what I have put in the form for ins_ref_no. However the resource id is not the desired output, it should have been 34 (or whatever is- which is id corresponding to the data that have been inserted with the $add_claim_details_sql.
  20. I inserted some data in mySQL table as follows: $add_claim_details_sql = "INSERT INTO claim_details (ins_ref_no) VALUES ('$your_ref_no')"; $add_claim_details_res = mysql_query($add_claim_details_sql) or die ("Could not edit item details:" . mysql_error()); so far so good - it works, great stuff, but ... ??? I would like to give some feedback to the user, ie, I want to supply the user who's submitted the form with a ref. no. The ref. no is the id from claim_details. (the id is set to be a primary key auto-increment). so I was hoping to achieve this by writing the following script: $query = "SELECT id FROM claim_details WHERE id=".$_GET['id']; $result = mysql_query($query)or die("Could not get your ref. no.:" . mysql_error()); echo $result; Obviously it does not work as I get the following error: I do not how to identify the id - which will be the reference number unique to the just submitted form. I hope my question makes sense and someone will help. Thanks!
  21. Dear turtleman8605, dear eddierosenthal, You are so right, I changed it and it works, MANY THANKS I'm so happy because I just registered in this forum and now I see I can actually get help from clever people like you! Otherwise I felt so helpless Thank you!
  22. Hi guys, I'm a student and very new to PHP, hence you might find my question stupid, but I cannot see the problem. My query is as follows: $add_claim_details_sql = "INSERT INTO claim_details (ins_ref_no) VALUES ('$your_ref_no')"; when I echo it, I get: INSERT INTO claim_details (ins_ref_no) VALUES ('1') //1 is what I've put in the form so far so good, but when I go to mysql table and check if 1 exists under the ins_ref_no, there's nothing there, there's no entry in the table at all, even no id. I've set my id as primary key, auto_increment??? Earlier I was inserting the following: $add_claim_details_sql = "INSERT INTO claim_details (date_added, date_modified, ins_ref_no) VALUES (now(), now(), '$your_ref_no')"; and when I looked in my claim_details mysql table, the date_added and the date_modified columns were filled with the appropriate date, time really puzzled ??? can anyone help please? :'(
×
×
  • 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.