0

Hi..Have you created a program using ms word? i want my system display the records in ms word...when you click the submit button,ms word will open and you will see all the records saved from the database..What are the codes i will used.?tnx in advance..

2
Contributors
6
Replies
10
Views
7 Years
Discussion Span
Last Post by takeshi
0

You may export all data in ms word with the below code:

<?php
$vExcelFileName="export". ".doc"; //replace your file name from here.

header("Content-type: application/x-ms-download"); //#-- build header to download the word file 
header("Content-Disposition: attachment; filename=$vExcelFileName"); 
header('Cache-Control: public'); 

echo "hai";

?>

The above code is tested and export the text hai in word..

0

You may export all data in ms word with the below code:

<?php
$vExcelFileName="export". ".doc"; //replace your file name from here.

header("Content-type: application/x-ms-download"); //#-- build header to download the word file 
header("Content-Disposition: attachment; filename=$vExcelFileName"); 
header('Cache-Control: public'); 

echo "hai";

?>

The above code is tested and export the text hai in word..

ok i'll try to run that code..:)hmm you mean that the word "hai" will export from the ms word right? What if the problem is i have a voting system..and i want to have a summary report of all total votes of each candidates from the database.Because when you count the votes of each candidates,the counting process will be save in the database.My question is, i already have a link named "view report".When i click it,it should appear/open the ms word and display the total summay of the votes.Hmm anyway,what did you mean by the "build header to download the word file"? and "replacing the file name"?File name of what I'am going to replace?

Edited by takeshi: n/a

0

these all are posted "//" between is comment that will give u the information that where u can made any change in the script and also in the change file name section you could change your file name with your once that i will give it "export" in my code. you could change it with report or any other that you want.
and i will post your database code very soon here.

0

to create a download option for all counted vote you should use the below code:

<?php
$host = "localhost"; //change your host here
$user = "test"; //change your username here
$pass = "password";  //change your password here
$db_name = "database"; //change your database name

$db = mysql_connect($host, $user, $pass); //connect to databse
mysql_select_db($db_name, $db); //select database

$vExcelFileName="export". ".doc"; //replace your file name from here.
 
header("Content-type: application/x-ms-download"); //#-- build header to download the word file 
header("Content-Disposition: attachment; filename=$vExcelFileName"); 
header('Cache-Control: public'); 
 
$query = mysql_query("SELECT * FROM user_table WHERE your_condition");
while ($row = mysql_fetch_array($query))
{

echo "<center>Voting Summery</center><br/><br/>
Total Vote Received by $row['user'] : $row['vote_count']";

}
?>

you should use the above code in new file called download.php and link it with voting counting page. so your all counted vote is download.

0

to create a download option for all counted vote you should use the below code:

<?php
$host = "localhost"; //change your host here
$user = "test"; //change your username here
$pass = "password";  //change your password here
$db_name = "database"; //change your database name

$db = mysql_connect($host, $user, $pass); //connect to databse
mysql_select_db($db_name, $db); //select database

$vExcelFileName="export". ".doc"; //replace your file name from here.
 
header("Content-type: application/x-ms-download"); //#-- build header to download the word file 
header("Content-Disposition: attachment; filename=$vExcelFileName"); 
header('Cache-Control: public'); 
 
$query = mysql_query("SELECT * FROM user_table WHERE your_condition");
while ($row = mysql_fetch_array($query))
{

echo "<center>Voting Summery</center><br/><br/>
Total Vote Received by $row['user'] : $row['vote_count']";

}
?>

you should use the above code in new file called download.php and link it with voting counting page. so your all counted vote is download.

Ok..tnx for this..Because all i know to export in ms word is using VB..We used there 'data environment right for all the reports..Anyway,i'll try to run these codes and make a lot of changes in ms word..Sorry for the question again, but i doubting my coding in counting votes..In selecting or voting a particular candidate, i used these html code :

<h2><center>Select Candidates</h2>
					 
				     <p><table cellspacing=5 cellpadding=5>
					<tr>
					<th>President:</th>
					<tr></tr><td>1.Name presidents&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="pre1">&nbsp;&nbsp;<th><a href="">View Profile</th></a></td>
					<tr></tr><td>2.Name presidents&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="pre2">&nbsp;&nbsp;<th><a href="">View Profile</th></a></td>
					<tr></tr><td>3.Name presidents&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="pre3">&nbsp;&nbsp;<th><a href="">View Profile</th></a></td>
					</tr>
		
					<tr>
					<th>Vice President:</th>
					<tr></tr><td>1.Name vice presidents&nbsp;&nbsp;&nbsp;<input type="radio" name="vice1">&nbsp;&nbsp;<th><a href="">View Profile</th></a></td>
					<tr></tr><td>2.Name vice presidents&nbsp;&nbsp;&nbsp;<input type="radio" name="vice2">&nbsp;&nbsp;<th><a href="">View Profile</th></a></td>
					<tr></tr><td>3.Name vice presidents&nbsp;&nbsp;&nbsp;<input type="radio" name="vice3">&nbsp;&nbsp;<th><a href="">View Profile</th></a></td>
					</tr>

					<tr>
					<th>Secretary:</th>
					<tr></tr><td>1.Name secretary&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="sec1">&nbsp;&nbsp;<th><a href="">View Profile</th></a></td>
					<tr></tr><td>2.Name secretary&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="sec2">&nbsp;&nbsp;<th><a href="">View Profile</th></a></td>
					<tr></tr><td>3.Name secretary&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="sec3">&nbsp;&nbsp;<th><a href="">View Profile</th></a></td>
					</tr>

					<tr>
					<th>Treasurer:</th>
					<tr></tr><td>1.Name treasurer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="tre1">&nbsp;&nbsp;<th><a href="">View Profile</th></a></td>
					<tr></tr><td>2.Name treasurer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="tre2">&nbsp;&nbsp;<th><a href="">View Profile</th></a></td>
					<tr></tr><td>3.Name treasurer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="tre3">&nbsp;&nbsp;<th><a href="">View Profile</th></a></td>
					</tr>

					<tr>
					<th>P.R.O/Auditor:</th>
					<tr></tr><td>1.Name P.R.O/Auditor&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="p1">&nbsp;&nbsp;<th><a href="">View Profile</th></a></td>
					<tr></tr><td>2.Name P.R.O/Auditor&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="p2">&nbsp;&nbsp;<th><a href="">View Profile</th></a></td>
					<tr></tr><td>3.Name P.R.O/Auditor&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="p3">&nbsp;&nbsp;<th><a href="">View Profile</th></a></td>
					</tr>

					</table></p>
					 
					 <h2><center><input type="submit" value="     VOTE     "></h2>

I already have my counting process in php but i found a lot of trouble with all the codes..My friend of mine gave that counting process of votes..I used to run it but still there's an error occur.My question is, what is the codes for counting the votes based on i had created an html code above?You are selecting a specific candidate using "radio button"..then click "vote button if you're done in voting.."It should count and save in database.

Edited by takeshi: n/a

0

Hey, what conditions i'am going to put in the code that you've gave to me?there's a condition there..your coding did not worked at all..

Edited by takeshi: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.