Reply
database name appear next to radio button
Old 07-19-2004, 10:50 PM radio button with database name as value
Experienced Talker

Posts: 34
I have created a php script that list the databases on my server. I want the results to appear next to a radio button so when that button is chosen it will jump to another php script. I needed help getting started, I can't figure out how to have the results appear next to the radio button and jump to the other script. Example

*database1
*database2
*database3

so if I click on the radio button next to database1 it would jump to another script that would show the tables in that database.

I think the answer lies in this line:
$db_list .= "<input type='radio' name='dbnames' value=$db_names[$db_num]><br \>";

it displays the radio button but not the name of the database

Just a student trying to learn

This is what I have to far:
<?php

$connection = @mysql_connect("localhost", "username", "password")or die(mysql_error());

$dbs= @mysql_list_dbs($connection) or die(mysql_error());

$db_list ="";
$db_num =0;

while($db_num < mysql_num_rows($dbs)){
$db_names[$db_num] = mysql_tablename($dbs, $db_num);

$db_list .= "<input type='radio' name='dbnames' value=$db_names[$db_num]><br \>";

$db_num++;

}
$db_list .= "";?>
<HTML>
<head>
<TITLE>MySql Databases</TITLE>
</head>
<BODY>
<p><STRONG>Databases on localhost</STRONG>:</p>
<? echo "$db_list"; ?>
</BODY>
</HTML>

Last edited by cedtech23 : 07-20-2004 at 12:05 AM. Reason: provide more info
cedtech23 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 07-20-2004, 12:59 PM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
You need to encompass the name of the database with quotes.

Quote:
Originally Posted by cedtech23
I think the answer lies in this line:
$db_list .= "<input type='radio' name='dbnames' value=$db_names[$db_num]><br \>";

__________________
—Kyrnt
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Old 07-20-2004, 01:03 PM
cmonkey's Avatar
Ultra Talker

Posts: 268
try this:

PHP Code:

<?
$dbhost 
YOUR HOST;
$dbuser 'YOUR DB USERNAME';
$dbpass 'YOUR DB PASSWORD';

$link mysql_connect($dbhost$dbuser$dbpass);
$result mysql_list_dbs($link);

while(
$row mysql_fetch_array($result)) {
    echo 
"<input type='radio' name='dbnames' value='$row[Database]'> $row[Database]<br>";
}
mysql_close($link);
?>
that worked on my server.
cmonkey is offline
Reply With Quote
View Public Profile
 
Old 07-20-2004, 06:12 PM radio button that starts another scripts
Experienced Talker

Posts: 34
Thanks for the help. I don't want to start another thread unless I have to. I want when the user selects the radio button associated with a database.

That it will bring the user to another page that will list the tables within that database.

As it stands know only the first part is complete; which is a list of databases associated with a radio button.

Is their a way in PHP accomplish the second part of having the user bought to another page once they select a radio button with have to press a submit button.

This is the script so far:
<?php

$connection = @mysql_connect("localhost", "administrator", "bulls23")or die(mysql_error());

$result= @mysql_list_dbs($connection) or die(mysql_error());

echo "<b>Select Database</b><br \>";
while($row = mysql_fetch_array($result)) {
echo "<input type='radio' name='dbnames' value='$row[Database]'>$row[Database] <br>";
}
mysql_close($connection);


?>
cedtech23 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to database name appear next to radio button
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Webmaster Resources Marketplace:
Software Development Company | Webhosting.UK.com | Text Link Brokers 


   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12740 seconds with 12 queries