mattjtayl Posted November 13, 2007 Share Posted November 13, 2007 ok I have a question. My forum is setup so it dynamically posts 1 or more direct deposits depending on how many the user enters. The problem is it is only writing the first $POST to mySQL and not the subsequent ones. Do I need to store all the same $_POSTS[same name] in an array or can I do a $_POST[same name] +new_Count. Can i do this without using arrays, how does the $_POST variables. Look at my psudeo code to see what I mean, the syntax is right at work, but this is the best I can remember at home. here is some psuedo code [i]Forum code:[/i] InsertNewRowFunction() ..... code adds another Row to table.... new_count= 0; each time this function iss called { new_count ++ } table.insertRow table.insertCell(0) table.cell.innerHTML = "<select name ='deposit_select" +new_count+" ' id = 'deposit select" +new_count+" 'onchange = insertNewRowfunction()><option>none</option><option>direct deposit</option>" table.insercell(1) table.cell.innerHTML = "<input mask ="$######.##" name='deposit_amt"+new_count+ " 'id ='deposit_amt" + new_count+ '>" table.insertCell(2) table.cell.innerHTML = "<input name='routeNumber" +new_count " ' id = 'routeNumber"+new_count+" '>" table.insertCell(3) table.cell.innerHtML = "<input name ='accNumber" +new_count+ " ' id ='accNumber" +new_count +" '>" <table> etc ... <th> <tr> <td>Deposit?</td> <td>Deposit Amt</td> <td>Routing Number</td> <td>account number</td> </tr> <tr> <td> <select name ="deposit_select" id = "deposit select" onchange = insertNewRowfunction()><option>none</option><option>direct deposit</option> </td> <td> <input mask ="$######.##" name="deposit_amt" id ="deposit_amt"></td> <td> <input name"routeNumber" id = "routeNumber"></td> </td> <input name ="accNumber" id ="accNumber"></td> </tr> </select> </table> ... [i]php code in a different file[/i] <? open database $deposit_amt = array() $deposit_amt = $_POST['deposit_Amt'] $deposit_query = select deposit_amt from depositsTable foreach($deposit_amt as $amount) { execute $deposit_query } Now this code will only write to mySQL database on the first $_POST['deposit_amt'] all other subsequent $_POST['deposit_amt'] are completely ignored. Link to comment https://forums.phpfreaks.com/topic/77082-reading-an-array-of-_postdeposits/ Share on other sites More sharing options...
jscix Posted November 13, 2007 Share Posted November 13, 2007 *shivers at the thought of entering my bank account number and routing numbers anywhere online, ever again* Link to comment https://forums.phpfreaks.com/topic/77082-reading-an-array-of-_postdeposits/#findComment-390371 Share on other sites More sharing options...
bri0987 Posted November 13, 2007 Share Posted November 13, 2007 You have to use "deposit_Amt[]" in your form (not "deposit_Amt") That way all of your values will go into the array: $_POST['deposit_Amt'] use: print_r($deposit_Amt); to see the array. you can pull info from the array by using: $deposit_Amt[0] $deposit_Amt[1] $deposit_Amt[2] $deposit_Amt[3] etc etc etc etc Link to comment https://forums.phpfreaks.com/topic/77082-reading-an-array-of-_postdeposits/#findComment-390373 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.