query-executen

Gesponsorde koppelingen

PHP script bestanden

  1. query-executen

« Lees de omschrijving en reacties

--->> query.php <<---

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<HTML>
<HEAD>
<TITLE>SQL query invoeren</TITLE>
</HEAD>

<?php

$host
= "localhost";
$user = "beta";
$pass = "betapw";

?>


<FORM ACTION="mysql_test.php" METHOD=POST>
Selecteer de database voor query:<BR><BR>
<select NAME=database SIZE=1>

<?php
mysql_connect($host, $user, $pass);

$sqlquery = "SHOW databases";
$result = mysql_query($sqlquery);

while ($rowdb = mysql_fetch_array($result))
    echo ("<OPTION>" .  $rowdb[Database]);
?>

</SELECT><BR><BR>

Voer de SQL query in die gexecuteerd moet worden:<BR><BR>
<TEXTAREA NAME="query" COLS=50 ROWS=10></TEXTAREA>
<BR><BR>
<INPUT TYPE=SUBMIT VALUE="Executeer query!">
</FORM>
</BODY>
</HTML>


-->> mysql_test.php <<--

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<HTML>
<HEAD>
<TITLE>PHP SQL Code Tester</TITLE>
</HEAD>

<?php
$user
="username";
$password="password";
$host="localhost";

mysql_connect($host, $user, $password);

mysql_select_db($database);
$query = stripSlashes($query);
$result = mysql_query($query);
?>


Resultaat van query <b>
<?php echo($query); ?>
</b><HR>

<?php
if ($result == 0):
    echo("<B>Error " . mysql_errno() . ": " . mysql_error() . "</b>");
elseif (mysql_num_rows($result) == 0):
    echo ("<B>Query succesvol geëxecuteerd!</B>");
else:
?>


<TABLE BORDER=1>
<THEAD>
<TR>

<?php
                for ($i = 0; $i > mysql_num_fields($result); $i++) {
                    echo("<TH>" . mysql_fieldname($result,$i) . "</TH>");
                }

            ?>


</TR>
</THEAD>
<TBODY>

<?php
            for ($i = 0; $i < mysql_num_rows($result); $i++) {
                echo ("<TR>");
                $row_array = mysql_fetch_row($result);
                for ($j = 0; $j < mysql_num_fields($result); $j++) {
                    echo("<TD>" . $row_array[$j] . "</TD>");
                }

                echo("</TR>");
            }

        ?>


</TBODY>
</TABLE>


<?php
endif
?>


<HR><BR>
<FORM ACTION=query.php METHOD=post>
<INPUT TYPE=SUBMIT VALUE="Nieuwe query">
</FORM>
</BODY>
</HTML>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.