omardavinci Posted September 14, 2016 Share Posted September 14, 2016 At first i create the form very easy with php: $content = '<h4>Title 1</h4><form method="POST"><table><tr><td><input id ="1" type="text" name="valueToSearch" placeholder="Value To Search"></td><br><br></tr><tr><td><input type="submit" name="search" value="Filter"></td></tr></form></table><br>'; Obviously since if(isset[$_POST]) i did the query like this: $query = "SELECT id FROM `user` WHERE CONCAT(`id`) LIKE '%".$valueToSearch."%'"; But in my case i want to update $articles ($articles are the articles ordered by pages), i mean this: $page = isset($_GET['page']) ? (int)$_GET['page'] : 1;$perPage = 2;//Positioning$start = ($page > 1) ? ($page * $perPage) - $perPage : 0;$art = $database_connection->query("SELECT id FROM user");//Query$articles = $database_connection->prepare("SELECT id FROM user LIMIT $start,$perPage");$articles->execute();$articles = $articles->fetchAll();$resultado = $database_connection->query("SELECT COUNT(*) AS total FROM user");$fila = $resultado->fetch(PDO::FETCH_ASSOC);$total = $fila["total"];$pages = ceil($total/$perPage); In conclusion, my question is very short. how i can update $articles when someone use filter to filter the table. In other words, i am trying to search some way to update $articles and i am little lost. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted September 14, 2016 Share Posted September 14, 2016 Here we go again. Obviously since if(isset[$_POST]) i did the query like this:What does this statement mean? Obviously what? If the $_POST was NOT set what query would you do then??? $query = "SELECT id FROM `user` WHERE CONCAT(`id`) LIKE '%".$valueToSearch."%'";And this query - what ARE you concatenating here? Why the CONCAT? $page = isset($_GET['page']) ? (int)$_GET['page'] : 1; Your form shows you doing a POST, yet now you are retrieving values form the $_GET array. How is that possible? $art = $database_connection->query("SELECT id FROM user"); //Query $articles = $database_connection->prepare("SELECT id FROM user LIMIT $start,$perPage"); $articles->execute(); And now you do two queries to select all of the id values. Why? And finally you question us as to how to update 'articles' yet you aren't even attempting to do anything with 'articles' here. Nothing. And what are you talking about when you say "when someone use filter to filter the table"? Who is the 'someone' since it is your script and you decide what happens. And again - even you are not doing any filtering here. I would almost say that we are struggling to understand your English. But then I look at your php and I have a hard time understanding what you think you are doing there. Quote Link to comment Share on other sites More sharing options...
omardavinci Posted September 14, 2016 Author Share Posted September 14, 2016 Thanks a lot for your help. I am very thankful. You helped me a lot . Merci. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted September 14, 2016 Share Posted September 14, 2016 Really? I find it hard to believe. Methinks that was sarcasm. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.