Designing Database - html

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.

Related

EXCEL How to change the REST URL based on the cell parameters

I created a web query as below in Excel.
New Queries --> From Other Sources --> From Web
How do I pass in the cell value as a parameter to the Url?
I have search bunch of articles, including in the stackoverflow. None of them work.
There is 1 article says I can do this in VBA.
ThisWorkbook.Sheets("[SheetName]").QueryTables("[TableName]").Connection =
But it is not there.
Any one know how to do this?
More information:
It is connecting to a REST server, and geting back the JSON result.
I found an article discussing how to create a query link mine, but it has not options to add the parameters. Please see the link. Step 3 have the URL typed in.
https://success.planview.com/Planview_LeanKit/Reporting/Advanced_Reporting/030Configure_A_Connection_To_The_Reporting_API_With_Excel
Give the cell a name, e.g. pMyParameter.
Open the query editor and create a new blank query (New Query --> Other Sources --> Blank Query). Give that query a name similar (or same) to the cell name (let's call it pMyParameterQuery). Open the Advanced Editor and replace everything with the following.
let
Source = Excel.CurrentWorkbook(){[Name="pMyParameter"]}[Content]{0}[Column1]
in
Source
You'll see in the query list that this query does not return a table but text (or a number / date / ... depending on the contents of your named cell).
Now switch to your web query and open its Advanced Editor. Find the line that has the URL, probably something like this:
Source = Web.Page(Web.Contents("http://www.example.com?someParameter=someValue")),
Here you can use the result of the parameter-query in the URL like this:
Source = Web.Page(Web.Contents("http://www.example.com?someParameter=" & pMyParameterQuery)),

"Create or update" form behavior when hitting back button

I have the following workflow on a website:
Some user John Doe declares a company through form 1
(fields: name, head office location)
After John Doe submits (HTTP POST) form 1, he is redirected (HTTP 302) to company form 2 with additional legal information about the company.
The problem is, if John Doe hits the back button of his browser during step 2, he will land on the form 1, with data filled by the browser (using values he already submitted — that's what Firefox and major browsers seem to do).
John Doe might then think he can use this form to update some information (e.g. fix a typo in the name of the company) whereas he will actually create a new company doing so, as we don't know on the server side whether he wants to declare a new company or update the one he just created.
Do you know any simple solution to handle that problem ?
Use javascript/jquery script after the page is loaded to empty all the inputs. This will prevent confusion of "updating the company".
jQuery would look something like this:
$('#elementID').val('');
You can also handle the situation by manipulating the browser history
on load of form 2, and pass the CompanyId generated on submit of form 1 using querystring. So that you can actually update the company as the user
Suppose John submits form1.html, a unique CompanyId "1001" is generated and redirected to form2.html. Now on load of form2 you can modify the browser history form1.html?companyid=1001 using
var stateObj = { foo: "bar" };
history.pushState(stateObj, "page 1", "form1.html?companyid=1001");
Now, when the user click back button and submits the form1 again. you can check for companyid in querystring and update the company.
I think it is more user-friendly when user can return back to previous form and update it (instead preventing the described behavior).
I use in most cases similar way to handle described problem:
Let's assume that user is on the page /some-page, that contains "Create new company" button.
When the user opens this page, will be executed special method createOrFindCompanyDraft() on the server-side. This method creates new company "draft" record in DB (only for the current user). For example, draft record has primary key id=473. When you execute this method again it will return the same record with the id=473 (with "draft" status). "Draft" record should't display on any other interfaces.
And "Create new company" has link /company/common/473.
When user go to /company/common/473, you display form 1, that will be filled from "draft" record. At first time user will see empty form.
Technically user will update the existing record, but you can display "Create new company" title on the page.
Then user go to form 2, for example, /company/legal-info/473, you create similar draft record for the this form (similar to step 1).
When user submit the form 2, you will remove "draft" status from the record id=473 (and any related records).
Next time when user open page /some-page, will be created new draft record for the current user.
Browser history will contain:
/some-page
/company/common/473
/company/legal-info/473
/some-page2
I like this approach, because all form only update records. You can go to previous/next form many times (for example "Back"/"Forward" browser buttons). You can close browser, and open not completed forms tomorrow. This way doesn't require any additional manipulation with the browser history.
try this
<form autocomplete="off" ...></form>
And Another
Use temporary tables or session to store the Page 1 form data. If the page 2 form is submitted use the temporary data of page 1 which is stored in database or in session.
Use a Separate key (Hidden field ) in both page 1 and page 2.
Actually I thought of a trick to obtain that "create on first post, update after" behavior (just like the user thinks it should behave).
Let's say the step 1 form is at the URL /create_company/. Then I could have that page generate a random code XXX and redirect to /create_company/?token=XXX. When I create the company I save the information that it was created through page with token XXX (for instance, I save it in user's session as we don't need to keep that information forever) and when the form is submitted, if I know that a company was already generated using this token, I know the user used the same form instance and must have used the back button since the token would be different if he explicitly asked for another company.
What do you think ? (I initially thought there should be a simpler solution, as this seems a little bit over-engineered for such a simple issue)
This is more like a UX question.
I'd think that the solution lies within the information given to the user on that form, to help them understand what they're doing.
Set a title that says 'Create a company', for example, and set your submit button as 'Create Company' will help your user with that. Use a unique id when you create the company object, and pass the id back to the same URL in order to perform an update. You should then update your title and button that tells user that they are updating instead of creating.
In that sense I'd say it's better to use a more generic URL like /company and /company?id=12345.
You could also consider using Restful API protocol to help your server identifies the CRUD operation. http://www.restapitutorial.com/lessons/httpmethods.html
Without the "routing" part of django it is hard to help. I can just answer my experience from the express.js-router functionality:
you can specify a post on /company, which is for new users.
you can specify another route for post on /company/:companyid for a changing form
and as a response from the create-post you can redirect to the different location.

How can I change the domain of a URL within a varchar column?

I have a database structure where one of my columns (innerLink) has a URL within it.
So that innerLink column will have a URL structured as follows
http://www.123456.com/forums/showthread.php?t=123456
I wanted to change the http://www.123456.com to a wholly different URL --> http://789.123.com without affecting the rest of the URL structure (ie. /forums/showthread.php?t=123456 )
I need this change to hit every URL in that column that is on the 123456 domain. I have other URLs such as cnn.com or msnbc.com so I dont want those affected. The change should only be to make www.123456.com to 789.123.com
I've never done this type of manipulation with MYSQL before, so was hoping for a bit of guidance before I hose my entire database of about 4000 records :) I will be doing this through PHPMYADMIN
Thanks for any help!!
You want to use the REPLACE() string function
UPDATE `table` SET `innerLink` = REPLACE('www.123456.com', '789.123.com');

Can't save waypoints in Google maps v3

I downloaded this project:
http://vikku.info/programming/google-maps-v3/draggable-directions/saving-draggable-directions-saving-waypoints-google-directions-google-maps-v3.htm
To se how to save waypoints, I opened, the html, and tryied to save the waypoint, but it don't work, I dont know if i need to do something in SQL or not, I just tryied to make it works, please help me if you had sucess to make it works.
You have to:
create a DB with the name mapdir
create a table with the name mapdir inside this DB, the table should have only 1 field named value with the type text (there is a file mapdir.sql inside the ZIP-file, you may use it to create the table)
inside process.php you must edit line#5 and set the correct values for mysql_connect(servername,username,password)
You also should change process.php,Line#3 to
#$data = $_REQUEST['mapdata'];
....otherwise you later will not be able to load the waypoints when error_reporting is on.
But however, I wouldn't suggest to use this project like it is, there isn't any protection against SQL-injection.

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

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 :)