duanluo5096 2015-03-21 06:33
浏览 44
已采纳

更新表的列值并同时显示(PHP)

First of all, the system I am working on is a virtual HR system. Now, I have this profile.php page where the form for the applicant is located. The form is consists of her/his basic profile and requires him/her to set the skills the applicant has. When the applicant press the submit button, it will go to test.php where the page will display the possible jobs that the applicant is qualified into based on the skills of the applicant that he/she entered in the profile.php.

Now, I'm having this error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Specialist WHERE fname=Jamie' at line 2

Here's the code in the test.php where I'm trying to update and show the job column value in employee table.

        $last = mysql_query("SELECT * from employee ") or die(mysql_error());

        echo "<table border='0' cellpadding='15' text-align = 'center' >";
        echo "<tr>";

            echo "<th>Name</th>";
            echo "</tr>";
            while($row2 = mysql_fetch_array( $last )){  
                $nym = $row2['fname'];  
            }

        $result = mysql_query("SELECT * FROM employee as t1,jobs as t2
                where t1.skills = t2.skills ") or die(mysql_error());

        while($row = mysql_fetch_array( $result )){
                $jt = $row['jobtitle'];
                $hey = mysql_query("UPDATE employee
                            SET job=$jt
                            WHERE fname=$nym")
                            or die(mysql_error()); 

                echo '<th><b><font color="#663300">' . $row['job'] . '</font></b><br></th>';
        }

Here's the snapshot of my employee database http://snag.gy/i7pw6.jpg

  • 写回答

3条回答 默认 最新

  • dsutuyxe088689 2015-03-21 06:37
    关注

    change query like this...

     $hey = mysql_query("UPDATE employee
                                SET `job`='$jt'
                                WHERE `fname`='$nym'")
                                or die(mysql_error()); 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法