Jump to content

Using SQL and PHP


Cboyd13

Recommended Posts

Im trying to make a webpage, nothing fancy, just an input box and a submit button that when clicked will do 4 things:

    * Receives the SQL statement

    * Connects to the database "Database01"

    * Executes the SQL statement.

    * Echos the SQL statement

 

and I have written this so far:

<body>
<form name='Query' action="Database01.php" method="post">
<center>Query Statement<input name=sql>
<br>
<br>

<input type='button' value='Submit' onclick='submit()'>
<script>
     var n=confirm("Do you want to submit "$sqli");
     if (n==true){
     document.Query.submit();
     }
<?php
$mysqli=mysqli_connect('localhost','root','','Database01');
$sqli=$post;
$recordset=mysqli_Query($mysqli,$sqli);
while($data=mysqli_fetch_array($recordset,MYSQLI_ASSOC)){
	$post=$record
	echo "$row"
?>

 

I think im in the right direction, except I do not know how use the Query statement from the input box into PHP and then execute it. Any help would be appreciated, and forgive me if my code is sloppy or completely wrong, just starting to learn it.

Link to comment
https://forums.phpfreaks.com/topic/180680-using-sql-and-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.