Php 编辑和删除数据库中不使用存储过程的特定行

Php 编辑和删除数据库中不使用存储过程的特定行,php,mysql,Php,Mysql,我使用以下代码从中删除特定行,但无法正常工作。我有两个文件:brand.php和delete.php。这是密码。如何从数据库中删除特定行。 brand.php $sql = "http://www.query.mydomain.com/default.aspx?dbname=compname_dbName&query=select Code, Id, Name from Brand where CompanyCode = 87"; $sqlquery = str_replace ( "

我使用以下代码从中删除特定行,但无法正常工作。我有两个文件:brand.php和delete.php。这是密码。如何从数据库中删除特定行。

brand.php

$sql = "http://www.query.mydomain.com/default.aspx?dbname=compname_dbName&query=select Code, Id, Name from Brand where CompanyCode = 87";
$sqlquery = str_replace ( " ", "%20", $sql );
$json = file_get_contents ( $sqlquery );
$data = json_decode ( $json, TRUE );
$result = array ();
$i = 1;
foreach ( $data as $item ) {
    $Rowid = $item ['Code'];
    $BId = $item ['Id'];
    $BName = $item ['Name'];
    ?>
        <form method = "post" action = "">      
            <tbody>
            <tr>
            <td> <?php echo $Rowid; ?> </td>
            <td><?php echo $BId; ?> </td>
            <td><?php echo $BName; ?> </td>
            <td><p data-placement="top" data-toggle="tooltip" title="Edit">
<button class="btn btn-primary btn-xs" data-title="Edit" data-toggle="modal" data-target="#edit">
            <span class="glyphicon glyphicon-pencil"></span>
            </button>
        </p></td>
        <td><p data-placement="top" data-toggle="tooltip" title="Delete">
        <a href="delete.php?rid=<?php echo $Rowid; ?>"><button type="submit" id="rid" name="rid" class="btn btn-danger btn-xs">
            <span class="glyphicon glyphicon-trash"></span></button></a>
            </p></td>
        </tr>
    </tbody>
        </form>
    <?php $i++; } ?>
    </table>
$Rowid=$_GET['rid'];
    $sql = "http://www.query.mydomain.com/default.aspx?dbname=" . $GLOBALS    ['strDB'] . "&query=Delete From sp_DelBrand Where Code = ".$Rowid."";
    $sqlquery = str_replace ( " ", "%20", $sql );
    $json = file_get_contents ( $sqlquery );
    $data = json_decode ( $json, TRUE );
    $resultID;
    $Result1 = ' ';
    foreach ( $data as $item ) {
        $Result1 = $item ['Result'];
        $resultID = $item ['ResultId'];
    }
    foreach($data as $item)
        {
            $Result1 = $item['Result'];
            $resultID = $item['ResultId'];
        }
    echo '<script type="text/javascript">';
    echo 'alert("'.$Result1.'");';
    echo '</script>';
    if (!isset($Result1))
        {
            echo '<script type="text/javascript">window.history.go(-1);</script>';
        }
    else
        {
            echo '<script type="text/javascript">window.history.go(-1);</script>';
        }   
}
?>
$sql=”http://www.query.mydomain.com/default.aspx?dbname=compname_dbName&query=select 代码、Id、品牌名称,其中CompanyCode=87”;
$sqlquery=str_replace(“,“%20”,“$sql”);
$json=file\u get\u contents($sqlquery);
$data=json_decode($json,TRUE);
$result=array();
$i=1;
foreach($数据作为$项){
$Rowid=$item['Code'];
$BId=$item['Id'];
$BName=$item['Name'];
?>

delete.php

$sql = "http://www.query.mydomain.com/default.aspx?dbname=compname_dbName&query=select Code, Id, Name from Brand where CompanyCode = 87";
$sqlquery = str_replace ( " ", "%20", $sql );
$json = file_get_contents ( $sqlquery );
$data = json_decode ( $json, TRUE );
$result = array ();
$i = 1;
foreach ( $data as $item ) {
    $Rowid = $item ['Code'];
    $BId = $item ['Id'];
    $BName = $item ['Name'];
    ?>
        <form method = "post" action = "">      
            <tbody>
            <tr>
            <td> <?php echo $Rowid; ?> </td>
            <td><?php echo $BId; ?> </td>
            <td><?php echo $BName; ?> </td>
            <td><p data-placement="top" data-toggle="tooltip" title="Edit">
<button class="btn btn-primary btn-xs" data-title="Edit" data-toggle="modal" data-target="#edit">
            <span class="glyphicon glyphicon-pencil"></span>
            </button>
        </p></td>
        <td><p data-placement="top" data-toggle="tooltip" title="Delete">
        <a href="delete.php?rid=<?php echo $Rowid; ?>"><button type="submit" id="rid" name="rid" class="btn btn-danger btn-xs">
            <span class="glyphicon glyphicon-trash"></span></button></a>
            </p></td>
        </tr>
    </tbody>
        </form>
    <?php $i++; } ?>
    </table>
$Rowid=$_GET['rid'];
    $sql = "http://www.query.mydomain.com/default.aspx?dbname=" . $GLOBALS    ['strDB'] . "&query=Delete From sp_DelBrand Where Code = ".$Rowid."";
    $sqlquery = str_replace ( " ", "%20", $sql );
    $json = file_get_contents ( $sqlquery );
    $data = json_decode ( $json, TRUE );
    $resultID;
    $Result1 = ' ';
    foreach ( $data as $item ) {
        $Result1 = $item ['Result'];
        $resultID = $item ['ResultId'];
    }
    foreach($data as $item)
        {
            $Result1 = $item['Result'];
            $resultID = $item['ResultId'];
        }
    echo '<script type="text/javascript">';
    echo 'alert("'.$Result1.'");';
    echo '</script>';
    if (!isset($Result1))
        {
            echo '<script type="text/javascript">window.history.go(-1);</script>';
        }
    else
        {
            echo '<script type="text/javascript">window.history.go(-1);</script>';
        }   
}
?>
$Rowid=$\u GET['rid'];
$sql=”http://www.query.mydomain.com/default.aspx?dbname=“$GLOBALS['strDB']”和query=Delete From sp_DelBrand Where Code=“.$Rowid.””;
$sqlquery=str_replace(“,“%20”,“$sql”);
$json=file\u get\u contents($sqlquery);
$data=json_decode($json,TRUE);
$resultID;
$Result1='';
foreach($数据作为$项){
$Result1=$item['Result'];
$resultID=$item['resultID'];
}
foreach($数据作为$项)
{
$Result1=$item['Result'];
$resultID=$item['resultID'];
}
回声';
回显“警报”(“$Result1.”);
回声';
如果(!isset($Result1))
{
echo“window.history.go(-1);”;
}
其他的
{
echo“window.history.go(-1);”;
}   
}
?>

单击删除图标后,没有重定向到delete.php?id=rowid的迹象,但是页面加载并返回brand.php,行记录没有被删除,我怎么了

这是PDO连接和删除行的查询:

<?php

$id = 5;

$dbh = new PDO('mysql:host=localhost;dbname=deletelimit10', "root", "");

$query = $dbh->query("DELETE FROM content WHERE id = '$id'"); // Run your query

?>

为什么:$sql=”“$GLOBALS['strDB']。“&query=Delete From sp_DelBrand Where Code=“.$Rowid.””$sqlquery=str_replace(“,“%20”,“$sql”);相反:$sql=“从sp_DelBrand中删除,其中代码='$Rowid'”;这是使用存储过程的兄弟!我不使用直接数据库连接方法。一旦此url与相应的值一起发布,我的存储过程将完成所有工作。。,