in Education by
why it's not working.. i want to update my table in database this is my code. for ($i=0; $i <83 ; $i++) { $link="this is test".$i; $sql = "UPDATE tbl_gallery_images SET thumbnail_url='$link' WHERE gallery_id=1"; // Prepare statement $stmt = $conn->prepare($sql); // execute the query $stmt->execute(); echo $link."
"; } when i echo that link it's show 100% right but in db just update 82 number in all rows even it is in loop. thanks in advance. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
UPDATE tbl_gallery_images SET thumbnail_url = '$link' WHERE gallery_id = 1 As it is, this query updates column thumbnail_url in all records that have gallery_id = 1. Running the same query 84 times in a loop results in the same set of records being updated again and again in each iteration, with an increasing thumbnail_url. After the last iteration, all records where gallery_id = 1 end up with thumbnail_url = 'this is test83. A sensible solution would be to add another criteria in the WHERE clause, in order to update just one record per iteration. Assuming that you have some integer column called id to disambiguate the records where gallery_id = 1, you would typically go: `UPDATE tbl_gallery_images SET thumbnail_url = '$link' WHERE gallery_id = 1 AND id = $i`

Related questions

0 votes
    I'm getting an error with this function: Controller $data['carSubwoofers'] = $this->db->get_where(" ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    I do know that PDO does not support multiple queries getting executed in one statement. I've been Googleing ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
0 votes
    I have multiple tables like make, model and year etc and using joins. I would like to search from ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 26, 2022 in Education by JackTerrance
0 votes
    I have multiple tables like make, model and year etc and using joins. I would like to search from ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    Symfony version: 3.1.3 Due to development reason suddenly my app giving the following error and I believe ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 8, 2022 in Education by JackTerrance
0 votes
    Hello! Like in title. There is code example. Result is: Nulla eu aliquet sapien. Sed in sagittis ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Hello! Like in title. There is code example. Result is: Nulla eu aliquet sapien. Sed in sagittis ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Registering members and allowing them to login (updating tables etc) all worked fine up until I made this change recently. ... , make the UserLevel 'Member'? Code for signing up:...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    I am looking to get row count to check if same email is already in database or not. i have tried ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I'm not sure why this SQL query is not working. I'm new to SQL/PHP so please forgive. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jan 13, 2022 in Education by JackTerrance
0 votes
    I'm not sure why this SQL query is not working. I'm new to SQL/PHP so please forgive. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jan 13, 2022 in Education by JackTerrance
0 votes
    I'm trying to append zeroes to a blob field in a sqlite3 db. What I tried is this: UPDATE Logs ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    How can I apply my div position x value to a variable? And how to iterate it in a for loop? ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    So I have a for loop that I want to output a new line in a textview every single time it goes ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 10, 2022 in Education by JackTerrance
0 votes
    I've got an output from an API call as a list: out = client.phrase_this(phrase='ciao', database= ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
...