kbensch Posted October 24, 2008 Share Posted October 24, 2008 Hi Everyone I am so new to php and I need to change a webpage by adding a download button. I really hope someone can help me. I have a webpage that lists rows in a mysql table. How do i add a download button that will output that to a csv file? Any help would really be appreciated. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/130000-extreme-newbie-need-urgent-help-please/ Share on other sites More sharing options...
Maq Posted October 24, 2008 Share Posted October 24, 2008 Can we see your current code? Quote Link to comment https://forums.phpfreaks.com/topic/130000-extreme-newbie-need-urgent-help-please/#findComment-673957 Share on other sites More sharing options...
kbensch Posted October 24, 2008 Author Share Posted October 24, 2008 Hi here is the code for the page that lists the records. Not created by me. I need to add a button at the end that will let me download the data. Thanks Kobus Quote Link to comment https://forums.phpfreaks.com/topic/130000-extreme-newbie-need-urgent-help-please/#findComment-673967 Share on other sites More sharing options...
Maq Posted October 24, 2008 Share Posted October 24, 2008 Where...? Quote Link to comment https://forums.phpfreaks.com/topic/130000-extreme-newbie-need-urgent-help-please/#findComment-673969 Share on other sites More sharing options...
kbensch Posted October 24, 2008 Author Share Posted October 24, 2008 Oh duh me 2nd try <html> <head> <title>Current Registrations</title> <link rel='stylesheet' type='text/css' href='main.css'/> </head> <body> <?php include_once("dbconnect.inc.php"); include_once("tables.inc.php"); $sqlQuery="SELECT * from ". DB_MYTABLE ." where 1"; $result = mysql_query($sqlQuery); if(!$result) die("<p>Unable to execute query = " . mysql_error() ); $numRows = mysql_num_rows($result); output_table_header(); output_banner(); // Define your username and password $password = "password"; if ($_POST['txtPassword'] == '') { ?> <br> <br><br> <br> <div align="center">Please enter your password to access this database. <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <p align="center"><label for="txtpassword">Password:</label> <input type="password" title="Enter your password" name="txtPassword" value="" /></p> <p align="center"><input type="submit" name="Submit" value="Login" /></p> </form></div> <?php } else if ($_POST['txtPassword'] == '' || $_POST['txtPassword'] != $password ) { ?> <br> <br><br> <br> <div align="center"> Invalid password, please try again: <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <p align="center"><label for="txtpassword">Password:</label> <input type="text" title="Enter your password" name="txtPassword" value="" /> </p> <p align="center"><input type="submit" name="Submit" value="Login" /></p> </form></div> <?php } else { outputTitle(); output_start_row(); output_cell_headers(); output_end_row(); while ( $record = mysql_fetch_assoc($result)) { output_start_row(); $recordID = $record['id']; output_cell_contents($record['firstname']); output_cell_contents($record['surname']); output_cell_contents($record['job']); output_cell_contents($record['company']); output_cell_contents($record['email']); output_cell_contents($record['phone']); output_end_row(); output_start_row(); output_end_row(); } output_table_footer(); } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/130000-extreme-newbie-need-urgent-help-please/#findComment-673973 Share on other sites More sharing options...
kbensch Posted October 26, 2008 Author Share Posted October 26, 2008 Is there anybody that can help me with this please? Quote Link to comment https://forums.phpfreaks.com/topic/130000-extreme-newbie-need-urgent-help-please/#findComment-675119 Share on other sites More sharing options...
Prismatic Posted October 26, 2008 Share Posted October 26, 2008 Do you want just a single row output to CSV or the entire database? Quote Link to comment https://forums.phpfreaks.com/topic/130000-extreme-newbie-need-urgent-help-please/#findComment-675133 Share on other sites More sharing options...
kbensch Posted October 26, 2008 Author Share Posted October 26, 2008 Hi Thank you for answering. The entire table. Not the whole database. Kobus Quote Link to comment https://forums.phpfreaks.com/topic/130000-extreme-newbie-need-urgent-help-please/#findComment-675134 Share on other sites More sharing options...
kbensch Posted October 27, 2008 Author Share Posted October 27, 2008 Hi all I sorted this this. Quote Link to comment https://forums.phpfreaks.com/topic/130000-extreme-newbie-need-urgent-help-please/#findComment-676020 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.