473,500 Members | 1,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to store content in MySQL Database by selected category?

ilya Kraft
134 New Member
Hello,

I came across following problem. I need to sort content by categories on my web page. Just like in bytes.com. User chooses area that is related to his / her question (PHP, JavaScript, HTML etc.) So when someone clicks on PHP section He / She only sees Posts related to Selected category (PHP Category).
I need to make something similar for my website, where user enters his content and than selects option. So selected option than get's stored in database and Then I can filter content by categories to show on my website.
I will attach image to explain it in more depth.

http://bytes.com/attachment.php?atta...1&d=1305454554

I don't understand how to make part 2 and part 3 of this process. I know how to make field with options, but how do I store them in database and how do I filter by categories after?

Please let me know if you need more explanation.

Thank You
Attached Images
File Type: jpg Untitled-1.jpg (25.7 KB, 5 views)
May 15 '11 #1
2 3375
johny10151981
1,059 Top Contributor
You Can do it in Simple old HTML Method.
step 1: When the page is load for the first time
Expand|Select|Wrap|Line Numbers
  1. if(isset($_POST['Category'])==true)
  2. {
  3.  $Category=$_POST['Category'];
  4. }
  5. else $Category="";
  6. /*
  7. Create Slelect view 
  8. */
  9. if($Category!='')
  10. {
  11.  /*
  12.  Select Second View
  13. */
  14.  
  15. //and so on. You will have to do a little clever programming which must disturb the user.
  16. }
  17.  
Or I Will Suggest you to consider AJAX.
What is Ajax?
In a simple word Ajax is newly(not new anymore) added method to send request to the server dynamically . Server will response normally.

In general When we request for a page Browser regenerate the document. But In Case of Ajax. You are the one to choose at what part you want to make the modification.

First Try To understand Ajax.

It will solve your all question here
May 16 '11 #2
ilya Kraft
134 New Member
Hello,

Thank you for reply, but I think you misunderstood me, because you suggested ajax. I don't need to update anything on the page. What I needed help with is different. I would like to know how to store selected option in database.

For Example:

User goes on my webpage and want's to post article, he writes the article and choses category from <select> list and then clicks submit button. How do I send selected option to database than?

I was thinking about making field in database and setting it to TEXT. then I would put values in which are categories names (for example Music, Arts, Cars ...)

But I cant figure whole process out, as I'm still new to server side programing. Here is what I have so far.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. include_once "scripts/connect_to_mysql.php";
  3. ?>
  4. <!doctype html> 
  5. <head>
  6. </head>
  7. <body>
  8.  
  9. <select name="Category" class="formFields" id="Category">
  10. <option value="01">Option 1</option>
  11. <option value="02">Option 2</option>
  12. <option value="03">Option 3</option>
  13. <option value="04">Option 4</option>
  14. <option value="05">Other</option>
  15. </select> 
  16.  
  17. </body>
  18. </html>
  19.  
I need to understand how to store selected option in database.

Thank You )))
May 16 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
2837
by: aa | last post by:
If I have an MySQL database on my local w2k, how do I transfer it onto my ISP server? The ISP gave me the name of an empty MySQL database they set up for me, the username and the password with no...
9
2207
by: Bob Bedford | last post by:
Where to find a comprehensive document on how take datas from XML and put them in a Mysql Database. I've many sites sending us XML files. We have to parse datas and save those datas on Mysql. ...
3
4900
by: Xerxes | last post by:
Hi, I would like to import the tables from MySQL database into Access database and I am not sure how to go about it. I tired to "Import External Data" from Access, selected "ODBC database" from...
5
3355
by: lawrence k | last post by:
I'm a little weak on my basic I/O. Help me out please. Is it right to say that I can just open any file with file(), get it as a string, and then store in a MySql database, in, say, a MediumText...
7
17869
by: mukeshpatil | last post by:
How to get data from .CSV file using php & store it into Mysql database I want to read data from two different .CSV files using php & How to store it into Mysql Database tables Please help me...
4
10321
by: grouchy | last post by:
hello all, not sure if i fully explained myself on an earlier post. All i really need to do is to store an xml file into mysql database. I have no idea how to do this, including any php code i...
0
1262
by: Ikke | last post by:
Hi everybody, At the moment I'm trying to figure out how to access my local database via C#. So far, I've succeeded in connecting and retrieving records. The results are displayed in a datagrid....
2
7052
by: sookfuny1984 | last post by:
I am facing a problem on how to parse (analyze) apache log file (access or error file) so that the data in log file will be imported to MYSQL database?? anyone can help?
1
3931
by: Akino877 | last post by:
Hello, I have a simple Perl program that connects to MySQL and creates a table of first names and last names. The code is as follows : #!/usr/bin/perl -w use DBI; use Mysql; use DBD::mysql;
1
12117
by: santhanalakshmi | last post by:
Hi, I wrote some coding, to import excel data in mysql database using PHP Script? But my script, its not all inserting the excel data in mysql database. I don't know, what mistake did i made?...
0
7014
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7229
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5485
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3108
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.