php - update my JOIN table -


i have built system can create category , document. categories live in cat_list table , documents live in doc_list table. there column in doc_list table called cat_no takes array or categories belong doc.

newfile.php

<?php  require_once '../../db_con.php';   try{     // selecting entire row cat_list table     $results = $dbh->query("select * cat_list");   }catch(exception $e) {     echo $e->getmessage();     die(); } $cat = $results->fetchall(pdo::fetch_assoc); ?>  <form action="actions/newdocadd.php" method="post" id="rtf" name="">     <input type="text" name="doc_title" id="doc_title" required="required" placeholder="document title"/><br />  <?php      foreach($cat $cat){         echo         '<input type="checkbox" value="" name=""> ' .$cat["cat_title"]. '</a><br>';     } ?>     <br><br>      <textarea name="doc_content" id="doc_content" placeholder="document content" style="display: none;"></textarea>     <iframe name="editor" id="editor" style="width:100%; height: 600px;"></iframe>      <br><br>      <input onclick="formsubmit()" type="submit" value="create document" name="submit"/>   </form> 

i have cut alot out of form because there alot of js because wysiwyg creator hence iframe. key area lsit out categories above checkboxes, need allow post number (or array of numbers if more 1 clicked) col_no column in doc)list table.

here script posts data:

<? session_start(); session_regenerate_id(); if(!isset($_session['user'])){        header("location: ../index.php");     exit; }   if(isset($_post["submit"])){ include_once'../../config.php';  try {    $dbh = new pdo("mysql:host=$hostname;dbname=dashboardr",$username,$password);  $dbh->setattribute(pdo::attr_errmode, pdo::errmode_exception); // <== add line  $sql = "insert doc_list (doc_title, doc_content, doc_created, user_id) values ('".$_post["doc_title"]."','".$_post["doc_content"]."', now(), '".$_session['user']."''".$_post['cat_no']."' )";      print_r($_post);  if ($dbh->query($sql)) {     header ('location: ../doclist.php?success=1'); } else{ }  $dbh = null; } catch(pdoexception $e) { echo $e->getmessage(); }  } ?> 

update

<?php      foreach($cat $cat){         echo         '<input type="checkbox" value="$cat["cat_id"]" name="cat_no"> ' .$cat["cat_title"]. '</a><br>';     } ?>   

so can post in value of "0" need array of id's of posting, doing wrong here?


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -