iRush Posted October 21, 2011 Share Posted October 21, 2011 Now that i have my code that shows my list on the localhost I want to try and put this into a table and beable to add a delete from the table. Here's my code any help would be much appreciated. <?PHP // please add login and pass here// $host = "localhost"; $login = "root" ; $pass = ""; mysql_connect("$host","$login","$pass") OR DIE ("There is a problem with the system. Please notify your system administrator." .mysql_error()); //Seems in this case we can use a general call $connection = mysql_connect("$host","$login","$pass") or die(mysql_error()); $dbs = @mysql_list_dbs($connection)or die(mysql_error()); $db_list="<ul>"; $i =0; while ($i < mysql_num_rows($dbs)){ $db_names[$i] = mysql_tablename($dbs,$i); $db_list .="<li>$db_names[$i]"; $i++; } //Start Create DB// IF (isset($_POST['result'])){ $database=$_POST['database']; $sql="CREATE DATABASE $database "; $result = mysql_query($sql,$connection) or die(mysql_error()); echo "Database $database has been added"; } IF (isset($_POST['delete'])){ $db=$_POST['db']; $query=mysql_query("DROP DATABASE $db"); echo "Database $db has been deleted"; } ?> <html> <head> <title>MySQL Databases</title> </head> <body> <p><strong>Databases on localhost</strong>:</p> <? echo "$db_list"; ?> <?PHP //print_r($_POST); ?> <form action="pretask.php" method="post"> <select name="db"> <?PHP $db_list = mysql_list_dbs($connection); while ($row = mysql_fetch_object($db_list)) { //Here you are listing anything that should not be included if ($row->Database!="information_schema" && $row->Database!="mysql" && $row->Database!="phpmyadmin"){ echo "<option value=\"".$row->Database."\">".$row->Database."</option>"; } } ?> </select> <input type="submit" name="delete" value="Delete"/> </form> <form action="pretask.php" method="post"> Create Database <input type="text" name="database" /> <input type="submit" name="result" value="Create" /> </form> </body> Quote Link to comment https://forums.phpfreaks.com/topic/249499-making-a-list-into-a-table/ Share on other sites More sharing options...
iRush Posted October 21, 2011 Author Share Posted October 21, 2011 Anyone have any ideas Quote Link to comment https://forums.phpfreaks.com/topic/249499-making-a-list-into-a-table/#findComment-1281022 Share on other sites More sharing options...
iRush Posted October 21, 2011 Author Share Posted October 21, 2011 I just want to put this list into a table a simple list from my localhost into a table Quote Link to comment https://forums.phpfreaks.com/topic/249499-making-a-list-into-a-table/#findComment-1281030 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.