I'm really new to FuelPHP and trying to do a search form that will display results from my db. I've found a couple of fragments here and there that give me clues about how to go about doing this but no single example that I can follow from start to finish.
Doing a search on "search" doesn't provide very much.
If anyone can point me to an example that allows me to determine, in baby steps, what to do, I would really appreciate it.
I want to have a search form with an input and button which will then show me results from querying mysql db.
That doesn't work any different in FuelPHP then in other frameworks, or in native PHP.
You'll need a form where a user can type in search criteria, optionally a parser (so you can have searches for "this" AND "that"), and then you need to run a DB query, that returns whatever you want to look for.
There is no set way of doing all this, it depends on your requirements, database design, columns you want to search on, and the type of search you want.
Your answer isn't all that helpful. I could actually do this in regular old php with very little work. Telling me that I need a form where a user can type in search criteria is blindingly obvious and the part about needing to run a db query is priceless.
You replied to my question so I will accept that you have good intentions, but your answer itself is not helpful.
I know it is not very helpful, I was very clear about that.
If you say you can do it in "regular old PHP" easily, than you know exactly how to implement it. Which means the question is not "Search form", the question is "how do I build a simple FuelPHP application".
Given the fact that you're appearently an experienced PHP dev, writing a controller with a single action, a view with a form. a view for the output, and perhaps a model for the table should be doable within an hour. Especially because FuelPHP comes with commandline tools to generate most of it for you.
Yes, I can generate crud with oil and I suspect it would take less than an hour to do this. I haven't worked with MVC much so it's a little bit of a challenge. Ultimately, I guess what we're talking about is that I need to be able to pass a parameter in via a search form and get a result from the database.
I don't need a lot in order to figure it out, just an example that demonstrates this.
Your answer leaves a lot to be desired to put it mildly. Either you don't know how to do it yourself or you're too lazy to answer the question. Either way, I figured it out for myself and basically just did it the way I would do it in regular old php. So much for the framework.
I love fuelphp. I think it's a great tool, but my experience asking a simple question here has not been very impressive.
I assumed you didn't know Fuel at all, so I gave you the suggestion to look at the scaffolding code generated by oil, which contains all components you need to build any kind of form and processing the form submission. So you observe, examine, and learn how it works. Then implement your own form.
You contradicted that, you say you love FuelPHP, which means you must have already used it. You also say your are proficient in PHP. So writing a form with a single input field, accepting the posted value, stick it into a query, and get a result must be peanuts for you. At the same time, no indication whatsoever that you did look at documentation and generated code, no questions about how it works, stuff you need clarified, etc.
How difficult is it to look at a piece of generated code, to look at the documentation of controllers, models and views, and to code up a form with a single field?
Your reponses make it look like you're either not proficient in PHP at all (which is not a problem, we all have to start somewhere. But at least put some effort in), or you're just to lazy to look into it, and want someone to spoon-feed you. That is fine, but that person will not be me.
I went through the scaffolding code. Obviously I couldn't work out how to do a search form. Since there was a forum, I thought I might save a few minutes and see if anyone can shed some light on how to do it. I was thinking of something like, "You need to have blah in your controller and don't forget to put blah in your model."
After your first answer you admitted that it wasn't very helpful. But then you didn't give me any more information! When all else fails, blame the user.
I see that you are project lead so you obviously know quite a bit about the product. Unfortunately, you don't seem willing to comunicate much beyond vague generalities.
My advice to anyone reading this forum is to *run* not walk away from this product. Apparently it has lost momentum and has some serious issues with leadership.
I have a serious problem with your attitude, and that is why I respond like this.
You claim you have PHP experience. You claim you can code up a solution in stand-alone PHP "in a few minutes". Yet you don't seem to be able to grasp the simple few lines of code generated by oil, and making a search form is appearently beyond you. And you don't reply to my questions.
We've seen this behaviour here multiple times, from people that are too lazy to look into things, and want others to write the code for them. And I said I would not be the one to do that for you.
Could you be a little more caustic and combative? Because, you know, I've noticed that is a *really* effective way to encourage people to work with your product.
Then you'll have to answer my "what exactly do you want" question first. Your question is so generic and vague that I can't give an answer. Even if I reply with a completely coded search application it might not be what you want.
Do you want to know how to create a view? How to generate HTML in the view? How to create a Controller? How to display a view from a controller? How to process submitted form data? All of the above?
What have you already looked at? What part don't you understand and need help with?