Jump to content

worldcomingtoanend

Members
  • Content Count

    122
  • Joined

  • Last visited

Community Reputation

0 Neutral

About worldcomingtoanend

  • Rank
    Advanced Member

Profile Information

  • Gender
    Not Telling
  1. Thanks to all those who responded, especially the insightful help from the Moderator. By complex I mean something more challenging but at the same time not needing a team of developers. The university is shooting down any project that is simple, simple as in something that any one with no programming language skills can do if they use google very well. But thanks again wonderful people for your suggestions. Thats why we love phpfreaks.
  2. I am searching for a possible final year computer science project to do. If there is a complex PHP project I can attempt I will appreciate anyone who can give me suggestions. Thank you.
  3. You guys you are just awesome. I double checked my queries and i noticed that I was putting my code on top of the if statement that does the query. I must hv messed up unwittingly since i got stuck for a long time and kept experimenting with lots of code. So i simply had to take the closing bracket of the foreach loop and wrapped it around to make the if statement inside and voila everything updated as I needed. here is what i did: $arrayIDs; //array containing database table IDs $arrayVALUES; // array containing update data $combine = array_combine($arrayIDs, $arrayVALUES); foreach($combine as $key => $value)) { $element = "UPDATE TableToUpdate SET newUpdateData = '$value' WHERE ID = '$key'"; if($connection->query($element)===TRUE){ echo "voila u hv updated"; } } Thanks ginerjm, Macgyver, Barand for your patience and advice.
  4. concerning the IDs, they are not manually input. They are set as hidden since they are being fetched from the database. The only thing a user does is update changes on each form input box and when they click on update changes the new values in each input box is sent to the update page in an array together with a corresponding array containing the database IDs for each input box which technically is a row. Let me look at few things concerning the queries and will get back. Otherwise thanks so far for your inputs.
  5. The reason why I included this: $arrayIDs; //array containing database table IDs $arrayVALUES; // array containing update data is because I do not have problems with that part of the code. Thats why i put comments to indicate its an array getting values from elsewhere. I have no problem with that part at all and both my arrays are and will always be equal with corresponding ID and values. Below is more info regarding your questions $arrayIDs =$_POST['eid']; //get ID values(whic come as an array from posted form $arrayVALUES = $_POST['tDescription']; // get VALUES which come as an array from posted form $combine = array_combine($arrayIDs, $arrayVALUES); print_r($combine); //print to prove that each array element is EXACTLY corresponding. I honestly hv no problem with this part. I dont understand when u say the query never runs. As far as I know the query is running without any problem but its only updating the last element of the array. I hv not included here the database connections. Do you want to see the entire code with the database connections? I hv no problem with that since I have already made dozens and dozens of connections. The only hiccup is what I hv stated. Also If the array size is 1, that is, if there is 1 element then it gets updated without any problem. From my research its got to do with something involving for loops and updating mysql tables.
  6. Thanks ginerjm, i tried what u said but it gives me the same exact result as my first attempt. Only the last element gets updated. This is what I did: $arrayIDs; //array containing database table IDs $arrayVALUES; // array containing update data $combine = array_combine($arrayIDs, $arrayVALUES); foreach($combine as $key => $value)){ $element = "UPDATE TableToUpdate SET newUpdateData = '$value' WHERE ID = '$key'"; }
  7. I have 2 equal arrays. 1 has ID values for the database table and the other has the corresponding update data. The array lengths keep changing as new data at different times is updated. However they will always be equal. How do I go about updating my mysql database table by extracting each ID from the array and then use that to commit the necessary update with the corresponding data in another array. Below is what I have tried but It only updates the last element and nothing else: $arraysIDs; //array containing database table IDs $arrayVALUES; // array containing update data for ($x = 0; $x < count($arraysIDs); $x++){ $element = "UPDATE TableToUpdate SET newUpdateData = '$arrayVALUES[$x]' WHERE ID = $arraysIDs[$x])"; } Thank you for your help.
×
×
  • 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.