Jump to content
The Uniform Server Community

Inserting Link key values to MySQL


 Share

Recommended Posts

Hello,

 

I am trying move data stored in an HTML hyperlink to MySQL. My understanding is that I have to use PHP to do this. My hyperlinks to the new page looks like this:

 

<a href="info.php?ProdNum=123&ProdName=Shoes">

 

On the "info" page I have have created a cookie to hold these values and I can print them out on the 'info' page. I have also created a table named "cart" to hold the cookie. The table "cart" is located inside the database "store" (MySQL). This table is part of the database that I'm using in this site.

 

Now, I need to insert the values from the link into my "cart" table. Because all the data for the insert is coming off my links, I don't need a lot in the way of 'die' statements and would prefer to not have them so that the working code is easier to see. If I must have 'die' statements, then so be it.

 

Thanks!!

 

-Steve

Link to comment
Share on other sites

Moved the topic to the right forum.

 

info.php?ProdNum=123&ProdName=Shoes

 

From my understanding, what you are trying to do is that when that link is processed through a browser, it moves 123 to the column .ProdNum. in the MySQL table and the same thing for the .ProdName. column in the table right?

Link to comment
Share on other sites

Yes, your understanding is right. I want to take embedded link data that is stored in key/value pairings and move that data into a MySQL table that has already been built (so I assume I'll be using an INSERT command. However, I have to open the dtabase and table and then apply the right insert command (I've seen several versions on the web and they are almost all aimed at moving form data to a MySQL table instead of hyperlink data.

 

I am assuming that I'll have to use a cookie to provide the proper format, but that seems duplicative (if such a word exists). I'll be happy with a cookie or cookie-less solution, just so the link data ends up in the table. This table will only hold the shopping cart data and I plan on running a "DELETE" (data) query after the deal has been approved (again, this is a school project and my aim is to show the process as cleanly as possible. I'll come back and deal with "best practices" after they've seen the skeleton).

 

Thanks!!

 

-Steve

Link to comment
Share on other sites

If you search google, i am sure you will find plenty of examples... and code snippets that will do what you are trying to do....

 

Yes what you are trying to do is an INSERT, and yes before that ofcourse you have to connect to the database and select the table and all that other good stuff... and then INSERT $ProdNum to COLUMN....

 

I am too bus right now or i would help you futher but this should be easy for you to do.. just search google for PHP/MySQL Code Snippets.... and start looking at them....

 

If you need more help after writing something, i can help you fix it and have it working after you come up with something.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...