Jump to content

kanz

New Members
  • Posts

    5
  • Joined

  • Last visited

kanz's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. right, Where is the problem in my code, you can answer my question?
  2. it's my code $Post_attid = $_POST[attid]; try { $sql = ('INSERT INTO attachments (attstatus, postsID, atturl, atttype, attcaption, attordering, attwidth_incontents, itsfirst, itssecond) (SELECT * FROM attachments WHERE attid = ?)'); $stmt = $conn->prepare($sql); $stmt->bindValue(1, $Post_attid, PDO::PARAM_INT); $results = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach($results as $row) { $stmt->execute($row); } } catch(PDOException $e) { echo $e->getMessage(); }
  3. I'm using field1 field2 for other field not mean the primary key. Ok, you right but i just want to duplicate a row of table according to "attid" posted not attempting to insert attid, this is primary key and auto-increment, not need to insert it by query.
  4. thanks Barand, 1 field is primary key In "loop rows" automaticaly auto-increment the field. For example, when we are attempting attach 10 files to a post, is this have a problem?
  5. hi I want to use url attachments for other post instead upload files again. Duplicate row(s) of attachments table with "attid field" posted from form and change a "postid field" in same table. I have a form with some input checkbox. The values of input are numbers which point to values of the field in database (attachments table > attid field ). <input type="checkbox" name="attid[]" value="10" /> <input type="checkbox" name="attid[]" value="250" /> This "attid" field is a Primary Key and AUTO_INCREMENT. I want when form submit, duplicate a row(s) with "attid" posted. Used this > INSERT INRO - SELECT query with loop by for each but not succesful $sql = ('INSERT INTO attachments (field1, field2) (SELECT * FROM attachments WHERE attid= :attid)'); thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.