pcw Posted March 20, 2009 Share Posted March 20, 2009 Hi, I have written this script to select a database to backup <?php include("data/required.php"); if (!mysql_connect($dbhost, $dbuser, $dbpass)) { echo 'Could not connect to mysql'; exit; } $showtablequery = " SHOW TABLES FROM $db "; $showtablequery_result = mysql_query($showtablequery); while($showtablerow = mysql_fetch_array($showtablequery_result)) { $table = $showtablerow[0]."<br />"; print "<form action='sqlexport.php?cmd=sqlbackup' method='POST'>"; print "<select name='backupFile'>"; print "<option>Backup Database</option>"; print sprintf("<option value='$table/%s'>%s</option>", $table, $table); print "</select>"; print "<input type='submit' name='tmpupdate' value='update'>"; print "</form>"; print "</center>"; print ' </td> </tr> </table>'; } ?> However it prints a select menu for each table. I want to be able to select the table from one select menu. What do I need to change? Thanks Link to comment https://forums.phpfreaks.com/topic/150341-solved-new-select-and-mysql-error/ Share on other sites More sharing options...
Mchl Posted March 20, 2009 Share Posted March 20, 2009 Only print sprintf("<option value='$table/%s'>%s</option>", $table, $table); should be in 'while' loop. The rest should be outside. Link to comment https://forums.phpfreaks.com/topic/150341-solved-new-select-and-mysql-error/#findComment-789548 Share on other sites More sharing options...
pcw Posted March 20, 2009 Author Share Posted March 20, 2009 Thankyou Link to comment https://forums.phpfreaks.com/topic/150341-solved-new-select-and-mysql-error/#findComment-789557 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.