drwdvftp423507 2013-08-26 08:36
浏览 132

如何从数据库phpmyadmin获取值并显示

i need all values from database if i click button(get values) how can i ? please assist me any one is there any way to do this ?

this is my index.php

<script type="text/javascript" src="jquery-1.10.1.js"></script>
<form>
            <h1>Insert Data Into mySQL Database</h1>
            Name        <input name="name"      type="text" id="name"> <br><br>
            Lastname    <input name="lastname"  type="text" id="lastname"><br><br>
            Email       <input name="email"     type="text" id="email"><br><br>
            <input type="button" name="Submit" value="Submit" onclick="insertData()">
</form>

<button type="button">get values</button>
<div id="jcontent"></div>
        <script type="text/javascript">
            /* * Checking the Login - * */
            function insertData(){
                var data_get = {
                        'name_form': $('#name').val().trim(),
                        'lastname_form': $('#lastname').val().trim(),
                        'email_form': $('#email').val().trim()
                        };
                $.ajax({
                url     : 'insert_ac.php',
                type    : 'POST',
                data    : data_get,
                timeout : 30000,
                success : function(response_data, text, xhrobject) {
                        console.log(text);
                        if(text == "success"){
                            $('#jcontent').html('Data Inserted');
                        }
                        else if(text == "ERROR"){
                            $('#jcontent').html('data not inserted');
                        }
                    }
                });
            }
        </script>
/*******************************************************/
 this is my insert.php

 <?php



    mysql_connect('localhost','root','');
    mysql_select_db('loginthree');

    $table_name = "test_three";

    $name_form=$_POST['name_form'];
    $lastname_form=$_POST['lastname_form'];
    $email_form=$_POST['email_form'];

    $sql="INSERT INTO $table_name(name, lastname, email)VALUES('$name_form', '$lastname_form', '$email_form')";
    $result=mysql_query($sql);

    // if successfully insert data into database, displays message "Successful".
    if($result){
        echo "Success";
    } else {
    echo "ERROR";
    }




?>

<?php
// close connection
mysql_close();
?>

i need all values from database if i click button(get values) how can i ? please assist me any one is there any way to do this ?

  • 写回答

2条回答 默认 最新

  • dounue1965 2013-08-26 08:41
    关注

    Well firstly, insert a:

    return false;
    

    at the end of your insertData() function, in that way you prevent the refresh of the page so that the ajax call can load its data.

    Second you are returning Success and you are trying to read success, it's case sensitive and your code will not reach that if.

    Resolve these issues and get back to me

    评论

报告相同问题?

悬赏问题

  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端