Linking two html forms in backend and fetch data from mysql - php

I've to insert two html forms in a webpage, One is a dropdown which consists of the names of the attributes of a phone directory, and a text field where we can enter any value of the corresponding attribute(selected in dropdown) and generate the search results from the database. I am done with the front end and I've created a database as well. I really don't have any idea about that.
Can someone help me with linking both the forms and generating results in tabular format?

You will require PHP or another similar server-side scripting language to do that.
Please have a look at this tutorial on W3Schools.com
Languages required: HTML, PHP, SQL.

Related

Using json field in mysql for page content

I'm creating a website with laravel with a simple page builder where standard page have common fields but some other pages (like home) may have additional fields.
in this case is it good to use json field or another table like page_fields to store additional data?
I've seen many suggestion to avoid using json in term of performance and managing data (like where clause)
must note that in my case these fields will be used just to show them and also can be translated later
thanks in advance
Text would be more suitable along with some templating language like markdown to be stored in such column instead of pure html

Filter Table format view - Drupal 7

I'm looking for some help about "Custom View". I looked throw the internet but can't find it (maybe cause of my bad key words).
I created a custom view with a Table format. The goal is to display content (based on a content type) in a table.
I already have my content showing, I can reorganize rows by client/sector.. by clicking on the column header but now I'd like to :
Filter result depending on the string in an input textfield
and
Filter result using a dropdown menu
I guess It's client side, but I'm a beginner in drupal so it's a bit hard to find out.
Here is what I'd like :
http://hpics.li/175e64e
For the select filter, you should try using exposed filters in your view. In the filter section, add filter on the fields and expose them. If these fields are taxonomy reference fields it should work right away. Otherwise it depends : with entity reference I think Better Exposed Filters can be usefull.
With plain text fields it will be more difficult to get what you want (personnaly I give up on exposed filters when it becomes to complicated), but still possible with this approach and a bit of client side work.
The general idea is to create JSON view wich gets all differents values for a text field across the nodes, using Views Data Source (or get all nodes with fields values then fetch unique values for each fields in javascript).
On client side, on the page load make an ajax call to this view to get an array of all possible values, then build your select list using this array, and then do a client side filtering (using for example the excellent Isotope).
But in my opinion you need to take side : all with views and exposed filters (server side, can be hard and frustrating...) or all in JS (client side), mixing the two should result in a big mess...
For the plain text search box I would choose to work client side, Views won't be of any help I'm afraid.
You can also find good javascript plugins for table sorting / filtering like Datatables.
Good luck.

Search On Website using php variable - DOM Parsing

I want to search on website pragmatically using PHP like as we search on website manually, enter query on search box press search and result came out.
Suppose I want to search on this website by products names or model number that are stored in my csv file.
if the products number or model number match with website data then result page should be displayed ..
I search on below question but not able to implement.
Creating a 'robot' to fill form with some pages in
Autofill a form of another website and send it
Please let me know how we can do this PHP ..
Thanks
You want to create a “crawler” for websites.
There are some things to consider first:
You code will never be generic. Each site has proper structure and you can not assume any thing (Example: craigslist “encode” emails with a simple method)
You need to select an objective (Emails ? Items information ? Links ?)
PHP is by far one of the worst languages to do that.
I’ll suggest using C# and the library called AgilityHtmlPack. It allows you to parse HTML pages as XML documents (So you can do XPath expressions and more to retrieve information).
It surely can be done in PHP, but I think it will take at least 10x time in php compared to c#.

How to generate FORM that reflects MySQL table?

I want to generate HTML form based on MySQL table field. The generated input should reflect the type of the MySQL column, e.g. VARCHAR = text, TEXT = textarea, ENUM = checkbox, SET = radio, etc.
I think this kind of Lib is not available
But ya you can do it by making one table in your database that conatains details about form and retrive it and make HTML code dynamically
This is a two step problem.
First you need to analyse the database table. You can get column names, type, etc. using SHOW COLUMNS.
You need to generate the form based on the retrieved information.
Generating form can be as simple as iterating the array received from SHOW COLUMNS query and building HTML along the iteration, or using existing form generation libraries, e.g. Zend_Form or Dora.
Depending on your needs, there is existing software for reflecting and manipulating the whole database, e.g. phpMyAdmin. Furthermore, some frameworks provide means of reflecting the whole model (i.e. database table) in a form for CRUD operations, e.g. Symfony Forms.

HTML Table row edit/Delete

I have an HTML table with contents, I would like to have an feature of Edit/Delete to that table. How do I do it with PHP?
I actually think that this sounds more like a job for JavaScript, which can edit/remove rows on-the-fly and with much less code. (Implement some AJAX too, and you can edit/remove rows in database too).
But if you insist on using PHP, you might just want to add some GET parameters to the Edit/Delete links that would delete or edit those rows.
Well, there is a pure PHP way to do it, and then there is a combination of Javascript and PHP. You must use PHP one way or another if you want your changes to the database to be permanent as that is your gateway to communicating with the database (as far as I know you cannot do that with Javascript as that is client-based and runs entirely in your web browser).
If using just PHP, you must generate HTML documents for each change. E.g., you click on one cell in the table and that gets you to a new HTML page where the field is editable through an input element; or you can list all fields at once for that row and edit them all at the same time. The fields are then posted in a form to a PHP page which will take the new values and update the database (or insert new values or however you wish it to behave). Here's a tutorial for how to do this:
http://www.freewebmasterhelp.com/tutorials/phpmysql/1
You can also mix in some Javascript which allows a more interactive interface to modifying the values in a cell. However, this obviously requires more code and may be overkill for what you're trying to do. Nonetheless, here is a link which demonstrates just that and also shows the code:
http://www.java2s.com/Code/JavaScript/GUI-Components/Editabletablecell.htm
Hope this is what you're looking for.
EDIT:
Forgot that you also wished to delete content in the table. That is also explained in the first link.
If you intend to work with databases, and it seems like you have little understanding of how they work, pick up a good book like: SQL - The Complete Reference. When you have enough knowledge of SQL, look at PHP's PDO extension: http://php.net/manual/en/book.pdo.php

Categories