in Education by
I'm not sure why this SQL query is not working. I'm new to SQL/PHP so please forgive. mysql_query(" SELECT * FROM table WHERE name = " . "'Bob'" . while($i < $size) { $i++; echo "OR name = '"; echo $array[$i] . "'"; } . " ORDER BY id DESC " ); Dreamweaver gives me an error saying it is not correct but does not tell me what is wrong. Is it possible to put a while loop into an sql command? 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
you can not use a while in a string $where = ""; if ($size > 0) { $where .= " WHERE "; } while($i < $size) { $i++; $where .= "OR name = '".$array[$i]."' "; } $query = "SELECT * FROM table WHERE name = '".Bob."'".$where." ORDER BY id DESC"; mysql_query($query); (this code is not tested)

Related questions

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 wrote javascript code to solve the following problem >>> Write a function exponentiate that accepts two ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 5, 2022 in Education by JackTerrance
0 votes
    I have a program that loops through the lines of a book to match some tags I've created indicating ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    In the following program, if I set the variable $foo to the value 1 inside the first if statement, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    I was supposed to do this exercise: Write a program in C to print a frequency chart on the screen ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    I have the automata S'-> S S -> a | XbY X -> ε | aZ | Y Y -> b | XX z ... JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 3, 2022 in Education by JackTerrance
0 votes
    If I use a while loop for my below code, it is not giving the desired output, but when i use for loop i am anle ... x += 1 print(Comm) Select the correct answer from above options...
asked Jan 9, 2022 in Education by JackTerrance
0 votes
    convert the following into For loop; while(true) System.out.print(‘*’); (in java ) PLEASE ANSWER FAST… WILL MARK BRAINLIEST** Select the correct answer from above options...
asked Dec 31, 2021 in Education by JackTerrance
0 votes
    write a program to input a number and print table of the number using while loop Select the correct answer from above options...
asked Dec 31, 2021 in Education by JackTerrance
0 votes
    When we choose for loop and how it is deffernt from while loop Select the correct answer from above options...
asked Dec 25, 2021 in Education by JackTerrance
0 votes
    WHILE…LOOP is used when we know the number of iterations of a loop. True False Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
0 votes
    The while loop repeats a set of code while the condition is not met? (a) True (b) False I had ... java programming questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    What is the syntax of while loop in shell scripting?...
asked May 28, 2021 in Technology by JackTerrance
...