dtpk04526211 2012-07-27 07:54
浏览 35

http://example.com/main.php?add= [关闭]

I would like to create a php script where I am able able to do

http://example.com/main.php?add=[$id + 1]

It connects to a mysql database. $id is an integer, lets just say the value is 1 (just to be an example). I want it to gather the $id from a mysql table called scriptid. (column 0) I want it to select the column from a mysql table called scriptlist. I want the column number to be the value of $id + 1, e.g http://example.com/main.php?add=2. When it does 'add' it will change the value of the column entered ($id + 1) to 1.

So far I have this, I am new to both php and mysql and am very confused, even after reading loads of guides.

$id = $_GET["id"];
$check = mysql_query("SELECT * FROM scriptlist");
$rowlist = mysql_fetch_row($check);
if($rowlist) {
mysql_query("UPDATE scriptlist SET user = 'dan' WHERE " . $rowlist['$id'] + 1 . " =     '1'"); 
echo($rowlist['$id'] + 1 . " = '1'");
}

I don't think my code will actually help you understand it more, but yeah.

  • 写回答

1条回答 默认 最新

  • duanjian4331 2012-07-27 09:32
    关注

    I am not sur of what you ask but maybe it's what you're looking for:

    $id = $_GET["id"];
    $check = mysql_query("SELECT * FROM scriptlist");
    $rowlist = mysql_fetch_row($check);
    if($rowlist) {
    mysql_query("UPDATE scriptlist SET user = 'dan' WHERE " . $rowlist[$id + 1]. " =     '1'"); 
    echo($rowlist[$id + 1] . " = '1'");
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答