PHP/MySQL - Improper stored data when submitted by users? -


First let me know that I have this script which allows users to enter more than one tag, for example separated by commas Gone html, css, php, mysql and stores each tag in the database and adds the question that was also tagged.

But for some reason this tag is not related to the questions_tags table correctly, about which I am saying and a better explanation about what I have to do. To give below table layout below?

Do I expect that I have explained it correctly?

Can someone give me some examples of the need to change something in my script to solve the problem?

What happens below this.

Table: Question_tag

  id tag_ id users_questions_id 1 1 3  

table: tag

  Id tag 1 html 2 css 3 php 4 mysql  

What do I want to do here below

Table: questions_tags

  id tag_ id users_questions_id 1 1 2 3 3 3 3 3 4 4 3 Table: Tags  
  ID Tags 1 HTML 2 CSS 3 PHP 4 ISSLL  

Here's my MySQL table.

  create table search ons tag (id INT unchecked precise attribution, tag_ id INT is not unknown, users_questions_id INT is not unreserved, primary key); Create a table tag (id INT is not unwritten, tap AuTegrment, Tag VARCHAR tap (255), primary key (ID));  

Below is my script.

  & lt; Php require_once ('./mysqli_connect.php'); $ ($ _ POST ['Submit']) {$ mysqli = New mysqli ("localhost", "root", "", "sitename"); $ Dbc = mysqli_query ($ mysqli, "SELECT questions_tags. *, tags. * from Prsn_tag Tags "); if (! $ Dbc) {print mysqli_error ($ mysqli);} $ p = '3'; $ tag = mysqli_real_escape_string ($ mysqli, $ _POST [ 'tag']); $ Mysqli = new mysqli ( "Sthaniyhost", "root", "", "sitename"); $ Dbc = mysqli_query ($ mysqli, "SELECT questions_tags. *, Tags. Add tag Prsn_tag INNER tag * .id = questions_tags. tag_id WHERE questions_tags.users_questions_id = '$ page' "); if (mysqli_num_rows ($ dbc) & gt; = 0) {if (isset ($ _ POST [ 'tag'])) {$ tag = explode (", " , $ _POST ['tag']); ($ X = 0; $ x & lt; count ($ tag); $ x ++) {$ mysqli = no Or mysqli ( "Sthaniyhost", "root", "", "Sitename") for; $ Clean_url = mysqli_real_escape_string ($ mysqli, $ page); $ Query1 = "tags (tags) to include values ​​( '.' Tags [$ X]. "')"; If (! Mysqli_query ($ mysqli, $ query1)) {print mysqli_error ($ mysqli); return; } $ Mysqli = new mysqli ("localhost", "root", "", "sitename"); $ Tag [$ x]. "" ");}} If (! $ Dbc) {print mysqli_error ($ mysqli);} and {$ SELECT id = '". $ Tag = $ dbc = mysqli_query ($ mysqli, while ($ row = mysqli_fetch_array ($ dbc)) {$ id = $ row [ "id"];}} $ Query2 = "Insert questions questions (Tag_ id, users_questions_id) VALUES ( '$ id', '$ page' ) "; if (! Mysqli_query ($ mysqli, $ query2)) {print mysqli_error ($ mysqli); return;}" $ tag entered "echo; if (! $ Dbc) {print mysqli_error ($ mysqli);} } Mysqli_close ($ mysqli);}? & Gt;  

is your best bet :

  1. Log into PHPMyAdmin on your MySQL server
  2. Manually ques Add an entry in the tions_tags column
  3. Copy and paste the MySQL query created by PHPMyAdmin into your PHP scripts

Wola!

< / Html>

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -