Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/130000-extreme-newbie-need-urgent-help-please/
Share on other sites

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>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.