Jump to content

Extreme newbie need urgent help please


kbensch

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.