dongnaizao8039 2016-12-31 11:03
浏览 51
已采纳

在sql表中复制一行

With the code below, im trying to duplicate a product row with ajax in a webshops table, named termek.

If the last product is ID 90, and i copy this, the new product will be ID 91.

Sometimes, and i dont know why, the ID 90(what i copyed), loose the image, the thumb and big cell in the table, or it is renamed or i dont know what going on.

Is this code okay for copying, or whats wrong whit it?

<?php
include_once("../../files/connect.php");
if(!empty($_POST))
{
    $id = mysqli_real_escape_string($kapcs, $_POST['id']);
    $sql = 
    "
        INSERT INTO termek
        (
                termek_nev,
                termek_seo,
                termek_rovid,
                termek_hosszu,
                termek_thumb,
                termek_big,
                termek_seo_title,
                termek_seo_rovid,
                termek_seo_kw,
                termek_status,
                termek_view,
                termek_akcio,
                termek_normal_ar,
                termek_akcios_ar,
                termek_cikkszam,
                termek_egyseg,
                termek_fooldal,
                termek_kiemelt,
                termek_suly,
                termek_keszlet_db,
                termek_keszlet_warning,
                termek_min_order,
                termek_allapot,
                termek_gyarto,
                termek_jobb_arat_btn,
                termek_tipus,
                termek_szavak
        )
        SELECT

                termek_nev,
                termek_seo,
                termek_rovid,
                termek_hosszu,
                termek_thumb,
                termek_big,
                termek_seo_title,
                termek_seo_rovid,
                termek_seo_kw,
                termek_status,
                termek_view,
                termek_akcio,
                termek_normal_ar,
                termek_akcios_ar,
                termek_cikkszam,
                termek_egyseg,
                termek_fooldal,
                termek_kiemelt,
                termek_suly,
                termek_keszlet_db,
                termek_keszlet_warning,
                termek_min_order,
                termek_allapot,
                termek_gyarto,
                termek_jobb_arat_btn,
                termek_tipus,
                termek_szavak

        FROM termek WHERE termek_id = '$id'

    ";

    if(mysqli_query($kapcs, $sql))
    {
        echo (int)1;
    }
    else
    {
         echo mysqli_error($kapcs);
    }
}
?>
  • 写回答

1条回答 默认 最新

  • dongpankao6133 2016-12-31 18:16
    关注

    To solve the problem, i uploaded a noimage.jpg to the products folder. When im editing the copied or the old product and changing its image, i dont delete the old image, if the thumb or big column == noimage.jpg.

    Sorry for bad english.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教