Jump to content

worldcomingtoanend

Members
  • Posts

    122
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

worldcomingtoanend's Achievements

Member

Member (2/5)

0

Reputation

  1. 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.
  2. 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.
  3. 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.
  4. 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'"; }
  5. 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.
  6. I need users to input ONLY numbers or letters with numbers. How can i go about fixing that. Thank you.
  7. May you help me with how to get a file handle for a checkbox. I mean something that will output a 1 or 0... thank you
  8. I only know how to extract public ip addresses using this: $_SERVER['REMOTE_ADDR']; $_SERVER['SERVER_ADDR']; but i need a way to extract a pc ip address...I need this to do a condition for a service available to the local intranet members. thank you..
  9. How can i make the script below not work if the webmaster logs into the CMS and wishes to access the page directly without the script redirecting him or her to a log in screen BUt at the same time making it possible for the script to remain working as it is for web users. Thank you in advance for your help..... Code: [select] <?php session_start(); if (!(isset($_SESSION['girls']) && $_SESSION['girls'] != '')) { header('location: ../mygirls/index.html'); exit; } ?>
  10. How can i make the script below not work if the webmaster logs into the CMS and wishes to access the page directly without the script redirecting him or her to a log in screen BUt at the same time making it possible for the script to remain working as it is for web users. Thank you in advance for your help..... <?php session_start(); if (!(isset($_SESSION['girls']) && $_SESSION['girls'] != '')) { header('location: ../mygirls/index.html'); exit; } ?>
  11. Is it possible to password secure a page online (yes that is possible i know) BUT have it unsecured if the web administrator accesses it locally on his CMS....My boss keeps saying he doesnt want to be entering a password if he opens the page inside the CMS. He says he doesnt want to be going through a lot of security checks since he owns the CMS but insists that that should only affect users online. The simple script I have is this : <?php session_start(); if (!(isset($_SESSION['girls']) && $_SESSION['girls'] != '')) { header('location: ../mygirls/index.html'); exit; } ?> How can i make the above script not work if this demanding boss logs into the CMS and wishes to access the page directly without the script redirecting him to a log in screen BUt at the same time making it possible for the script to remain working as it is for web users. Please help me I tried explaining to my boss but he keeps insisting that anything is possible with PHP. by the way he doesnt even know PHP:)
  12. thanks for replying me....but have tried that but it didnt help much........
×
×
  • 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.