Edit mySQL record inside HTML Table via double click - Is it possible? - mysql

I have an HTML TABLE that displays my records from mySQL.
I need to edit various records (rows). Is it possible to click on a table row and edit the values in the row inside the HTML table?
I was wondering if there are any PHP scripts out there to guide me?

Yes, it's possible. While I am very convinced PHP is involved, Javascript is involved also.
I think you can have something like this:
1.Click once, javascript increases a counter variable
2. Click twice, javascript checks if var = 2 after increasing, resets counter, and changes innerHTML of the td to something like this:
form action ='yourphpscript.php' method = 'getorpost'>
.....What you want to change....
</form>
3. So then it sends your values to the PHP script, PHP script changes values in database, and you get redirected back to the main page. Or, better yet, use AJAX.
Hope this helped :)

Related

Upload Text File Containing Long List of Tags to WordPress

I have a text file with about 6700 tags that I would like to add to my Word Press site. Of course, it is not efficient to do this manually. Is it possible to automate the insertion of these tags?
I tried a few plugins like Smart Tag Insert, but these are ineffective and have low review scores. Additionally, I see that tags in my MyPHPAdmin panel are stored in the table wp_terms. I wanted to write an SQL script that does what I need. However, the table also stores a series of other values (like menu names). There is no way to identify rows in this table as tags and not something else (like the name of a menu). So, I am also confused about that too.
Thank you for your time and help!
You should loop through all the tags in the file and then use the wp_insert_term function to insert the tags into the database.
Documentation : https://developer.wordpress.org/reference/functions/wp_insert_term/
So the first argument is the tag term and the second one is post_tag.
Exemple:
wp_insert_term(
'tag_name', // the term
'post_tag', // the taxonomy
);

Populate select box based on dropdown list

I am trying to get either a dropdown or selection box(prefer the later, because of the possibility to choose multiple values at once) in a webform.
In this case i already got the dropdown working, based on measures.measurement_type. The second needs to be measures.measurement, filtered by the type selected in the first dropdown.
I can not seem to get this working. I tried googling, but without succes. Can anyone help me get on the right track?
I found solutions using Arrays, but no working solution using 1 database table.
using ruby 4.2
Thanks
There are two options for this.
Using AJAX calls. Like #Ronan said in his answer, you need to make an AJAX call on the selection of first drop down (on change method). In the rails action method, you can render a JS partial where you can set the filtered items for second drop down.
Another one is totally client side. Like render all the possible items of both drop downs to client side. Meaning both type and measurements as javascript array. Then when changing the type drop down, filter the measurements array using jQuery and populate in the second drop down.
You gotta use some ajax for doing that, can't see other way. When your measures.measurement_type changes, you send a request passing that measurement_type as param for your action. In that action, you retrieve the collection of measurements based on the measurement_type passed in the param, and then return that data to be handled on your success ajax callback. On that method, with some jquery you should populate the second input with the options returned.
This is some simpler explanation... you should take some look at a more complete article for understanding step-by-step. Would suggest this one, for example: https://remysharp.com/2007/01/20/auto-populating-select-boxes-using-jquery-ajax. Good luck!

Not saving to db if form input fields are empty?

I have created Wordpress custom fields through functions.php. My code works fine, and I've few input fields and some checkboxes.
Problem is when I save post, even if I don't put content inside my form, these rows are created in DB. I'd like to do some kind of php check and avoid creation of row in DB if field content is not saved.
I tried several ways, but in most cases it would result in incorrect behaviors of checkboxes for example.
Full code is here: http://pastebin.com/embed_js.php?i=Vvnseiep
I'd appreciate your help in this matter. I'm not very experienced.
Thanks!
Here Validation part comes into play. Why cant you use Javascript to validate your input in the client environment itself and then allowing it to hit the db.
Name all of the checkboxes the same(name="meta_box_check[]"). They must still have different ID's. When the form is posted you will be given an array of values that were checked in $_POST['meta_box_check']. You can then check if the array is empty. You can also save the checkbox data as JSON data. This isn't always good practice, but will only use one data row to save any and all checkbox values.
<?php
if(!empty($_POST['meta_box_check']))
{
//process your data and save it
update_post_meta($post_id, 'meta_features_checklist', json_encode($_POST['meta_box_check']));
}
?>
This is a basic example and make sure you do some data validating before saving.

Mediawiki blank all pages per namespace. I want to blank all User_talk pages

I want to know if there is a way to blank all user_talk pages enmass. Not delete them, just blank them. I don't know how to write bots, so I'm really asking if there is an extension or pre written bot for this. Thank you
You could write a simple SQL to do this, just look into the page table, for my installation the namespace value for User talk: is 3, so I could just delete all pages with namespace=3.
Deleting the row from the database, will leave the page as blank (not created)
I suggest using AWB. You can easy have it build a list based on a names space and then use a simple ReGeX replace such as: Search: (.*)* Replace with: (empty space).

Designing Database

I need to design database with frontend as HTML.
This is my first attempt to do this.
What I need is,
- User can input a word from HTML page, click submit
I will query the word to get a URL from database and user sees that webpage(pointed by URL).
Just enter word, submit and get the webpage displayed.
People suggested using JSP/Access. I am new to everything.
Can you please point out what exactly I need to do?
Thanks a ton.
Following is the way you need to approach
Step1:
Create an HTML page which can take an input from the users
Step 2:
After getting the data from the user, create a connection to the database and pass the searched string as an input paramater.
Step 3:
You will get a result set from a database
Step 4:
Iterate through the result set and display in the html page, if you require the url to be given for those url, so when user clicks So that he will be directed to those websites.
Sample Query:
Select * from table1 where url_Word like '%Search_String'
This will be the procedure that you need to follow to complete your work.
You do not need a database you need a text file. If this is a school project you need more information.