473,624 Members | 2,305 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 3384
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
2861
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 further explanations. I came here from ASP/Access where I was just uploading a mdb file into my webspace. But with MySQL there should be a different procedure, should it not?
9
2220
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. The problem is that we have many different file format (each company sends us it's own XML structure). How to provide a simple way to get those datas in Mysql, without having to create a new PHP script for every new site's XML ?
3
4911
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 file type dropdown, selected "New data source" and picked SQL Server from the list. I specified the server name (mydomain.com) along with user id and password. But when I clicked on "Next", I got: "connection failed: SQL Server Error:10060,...
5
3366
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 field? I realize that MySql supports binary fields, but my current MySql schema does not have any binary fields, and I'm wondering if I can store the file without changing my current schema. Can I recreate the file later, if I wish, just be...
7
17889
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 to do this.
4
10332
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 need etc.. All i have done is create a database in mySQL and a table to get my login working. My xml file labelled cars.xml is below. <Feedback label = "Feedback">
0
1274
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. However, when I load the results again, I get an error: Unhandled Exception: Microsoft.Data.Odbc.OdbcException: ERROR 1046 No database selected
2
7061
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
3955
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
12129
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? Please help me out <?php $strPath = realpath(basename(getenv($_SERVER))); echo $strPath; $excel_app = new COM("Excel.application") or Die ("Did not connect"); $Workbook = $excel_app->Workbooks->Open('C:\san1.xls') or Die('Did not open...
0
8680
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8336
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8478
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7164
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6111
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4082
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2607
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 we have to send another system
1
1786
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.