php - How to give a user's question a URL based on it's ID in MySQL, so one may access it in the future? -


For some reason, I can not get my head about this concept. Any advice / signal will be appreciated if I currently have this code:

  if (isset ($ _ GET ['id']) // Check that id $ _GET $ Id = mysql_real_escape_string ($ _GET ['id']); // SQL injection to stop $ resc = mysql_query ("select message, title, discussion from where id = '$ id' range 1"); // query the DB for the record if (mysql_num_rows ($ resc) == 1) {// Make sure the question $ ques = mysql_fetch_assoc ($ resc) exists; // mysql converts resource into array that can be used in whole script}}  

OK, so the code above is given to me in this case a special line , and from that, can get the necessary information that I may need but what I want to know, what if I want to give the URL to that question? For example, when I post my question on the StackVareflow, it will probably be saved in a database, and will have to adopt an ID or some similarity, so community members and I can refer to it later. This will allow everyone to click on 'this' question because it will have a unique ID / reference similarly, I have a unique ID in the MySQL table for unique rows / queries, but I have a URL with that specific ID How can i get To wit. When I click on it, it will be directed to the actual question.
For example, the code I have shown above comes from savedisc.php , which has just acquired the idea of ​​a user in a form, a simple text in a MySQL table afterwards In, when I decide to reach this discussion, how can I 'click' on it? I definitely do not want to be directed to savedisc.php to see the user's discussion, but maybe savedisc.php? Whatever the case, the actual question information is actually linked to primary key ID = 115521 . Do I have to do another field or something?

Maybe I'm doing something wrong in the code below? It comes from savedisc.php :

  $ message = $ _POST ['message']; $ Heading = $ _POST ['title']; $ Represents = $ _POST ['represents']; $ Id = $ _GET ['id']; Include $ Sql ​​= "discussion (id, message, title, type) value ('', '$ message', '$ title', '$ represents')";  

Thanks.

Did you originally have your answer - by saying? ID = 115521, you pass a value for your PHP scripts, you get it by referring to $ _GET ['id'], means the way to add the URL to the database area Or am I doing you wrong?


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -