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..
hemgoyal_1990 5 Junior Poster
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..
takeshi 0 Junior Poster in Training
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 because: n/a
hemgoyal_1990 5 Junior Poster
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.
hemgoyal_1990 5 Junior Poster
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.
takeshi 0 Junior Poster in Training
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 <input type="radio" name="pre1"> <th><a href="">View Profile</th></a></td>
<tr></tr><td>2.Name presidents <input type="radio" name="pre2"> <th><a href="">View Profile</th></a></td>
<tr></tr><td>3.Name presidents <input type="radio" name="pre3"> <th><a href="">View Profile</th></a></td>
</tr>
<tr>
<th>Vice President:</th>
<tr></tr><td>1.Name vice presidents <input type="radio" name="vice1"> <th><a href="">View Profile</th></a></td>
<tr></tr><td>2.Name vice presidents <input type="radio" name="vice2"> <th><a href="">View Profile</th></a></td>
<tr></tr><td>3.Name vice presidents <input type="radio" name="vice3"> <th><a href="">View Profile</th></a></td>
</tr>
<tr>
<th>Secretary:</th>
<tr></tr><td>1.Name secretary <input type="radio" name="sec1"> <th><a href="">View Profile</th></a></td>
<tr></tr><td>2.Name secretary <input type="radio" name="sec2"> <th><a href="">View Profile</th></a></td>
<tr></tr><td>3.Name secretary <input type="radio" name="sec3"> <th><a href="">View Profile</th></a></td>
</tr>
<tr>
<th>Treasurer:</th>
<tr></tr><td>1.Name treasurer <input type="radio" name="tre1"> <th><a href="">View Profile</th></a></td>
<tr></tr><td>2.Name treasurer <input type="radio" name="tre2"> <th><a href="">View Profile</th></a></td>
<tr></tr><td>3.Name treasurer <input type="radio" name="tre3"> <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 <input type="radio" name="p1"> <th><a href="">View Profile</th></a></td>
<tr></tr><td>2.Name P.R.O/Auditor <input type="radio" name="p2"> <th><a href="">View Profile</th></a></td>
<tr></tr><td>3.Name P.R.O/Auditor <input type="radio" name="p3"> <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 because: n/a
takeshi 0 Junior Poster in Training
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 because: n/a
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.