Need, PHP Dropdown from mysql Database

JesterJoker

Regular Member
Joined
Jan 13, 2008
Messages
238
Reaction score
28
I have been messing with trying to get my code working for hours..

I have been trying to make a

php dropdown list, with a submit. Once submit is pressed pass that variable of the database selected, to edit 1 of my 34 databases with identical tables and fields.

---------------------------------

Pick from the dropdown list:

Dropdown > DB1
DB2
DB3
DB4
DB5

<SUBMIT>


Then that variable is passed into a select * statement, that chooses the database in choice.


Them my pages loads that shows the fields to edit from my database.



HELP!!!!


thanks.. in advance for any help.
 
PHP:
<?php
/*----------FORM SECTION------------*/
function form()
{
echo"<form action='' method='post'>";
echo "<select name='DB' value=''>DB</option>";
for($i=1;$i<=34;$i++)
	{
	echo "<option value=DB_$i>DB_$i</option>";
	}
echo "</select>";
}
/*-------END OF FORM SECTION-----*/


$DB=$_POST['DB'];

if($DB)
	{
	$handle = mysql_connect($host,$user,$pass);
	mysql_query("USE $DB",$handle);
	mysql_query("select * statement");
	}
else
	{
	form();
	}
?>

I hope that I helped

regards
 
I Havnt skimmed through the code to see the variables..

but will that populate the table to the screen?


I currently have this. There is 1 mysql statement it references to pick this database.


So really I want to put that dropdown above this to change all the settings "these fields, in every install of this bans store."



I also want to add 2 more mysql query's on the page, and tried to use a switch , but it didnt like that.


LOL, I really need to go back to school for coding. This is way better then IT work.
 

Attachments

  • screenshot.jpg
    screenshot.jpg
    53.5 KB · Views: 185
Last edited:
Right now it looks like this.

myaccount.php


PHP:
<?php

session_start();

if (!isset($_SESSION['user']))
{
header("Location: login.php");
}

include "config.php";


echo "<center>";

//checks see if there logged in
if($logged[id]) {
if(isset($_GET['update'])) {

$username = addslashes(htmlspecialchars($_POST[username]));
$password = addslashes(htmlspecialchars($_POST[password]));
$email = $_POST[email];
$site_name = $_POST[site_name];
$cj_pid = addslashes(htmlspecialchars($_POST[cj_pid]));
$title = $_POST[title];
$keywords = $_POST[keywords];
$description = $_POST[description];



//updates the options table
$update = mysql_query("UPDATE `options` SET `username` = '$username', `password` = '$password' , `email` = '$email', `site_name` = '$site_name', `cj_pid` = '$cj_pid', `title` = '$title', `keywords` = '$keywords', `description` = '$description' ");
echo "<h3>Selections Updated!</h3><br>";
}


$getuser = mysql_query("SELECT * FROM `options`");
$user = mysql_fetch_array($getuser);

echo "<h1>Basic Settings</h1>";



echo "<br><a href='login.php'>Back</a>";

echo "
<div id='container'>
  <div id='top'>
    <h1>Please complete the form below</h1>
  </div>";

echo "<form action='myaccount.php?update' method='post'>

Username: <input type='text' name='username' size='30' maxlength='55' value='$user[username]'><br><br>
password: <input type='text' name='password' size='30' maxlength='55' value='$user[password]'><br><br>
E-Mail: <input type='text' name='email' size='30' maxlength='55' value='$user[email]'><br><br>
Site Name: <input type='text' name='site_name' size='30' maxlength='55' value='$user[site_name]'><br><br>
Campaign: <input type='text' name='cj_pid' size='30' maxlength='55' value='$user[cj_pid]'><br><br>
Title: <input type='text' name='title' size='30' maxlength='55' value='$user[title]'><br><br>
Keywords: <input type='text' name='keywords' size='30' maxlength='55' value='$user[keywords]'><br><br>
Description: <input type='text' name='description' size='30' maxlength='55' value='$user[description]'><br><br>





</select><br>
<input type='submit' value='Update'>
</form>
<br>


";
}

else{

echo "You are not logged in, please login at http://www.mysite.com";
echo "<br><br><a href='login.php'>Login</a>";
}
echo "<center>";
?>


And my connection

config.php

PHP:
<?
session_start(); //allows session

$conn = mysql_connect("localhost","username","password");
mysql_select_db(my_bans) or die(mysql_error());

$logged = MYSQL_QUERY("SELECT * FROM `options`");
$logged = mysql_fetch_array($logged);

//some server details, don't edit!
$host = $_SERVER['HTTP_HOST'];
$self = $_SERVER['PHP_SELF'];

//change this to your site name
$sitename = "mysite.com";

//Send emails or not (email activation). 1 = true, 0 = false
$semail = "1";

?>

and my successive tables are named really as

name_1
name_23
name_4534
name_5434
name_45700

the category numbers for ebay.
 
Back
Top