Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Why my second isset function is not working..

Codes here !

Moderators: macek, egami, gesf

Why my second isset function is not working..

Postby Gamers » Tue Oct 30, 2012 9:42 am

Hi All,

I am try to export CSV report, for this first i display the table and at the bottom of this page i create a one button which is used to export the report, but its not seem to working. please check out my code,,,any help is appriciate.

if(isset($_POST['submit']))

{
$selectcondition = "SELECT DATE FROM baltimore where DATE='".$_POST['search']."'"; //Select Query Which check the date whether the checklist for the given date is exit or not.
$check=mysql_query($selectcondition,$con);
$fetch=mysql_fetch_row($check);

if(!$fetch) //If checklist for the given date is not exit execute if condition

{

echo '"<font color="red">';
echo "<br>";
echo "No Checklist Found In The Database";
echo "<br>";
echo "</font>";

}

else //if checklist for the given date is exit into the database execute this else part

{

$sql= "select DATE,JOBNAME,TIME,INITIALS,TIMESTAMP from $table where DATE='".$_POST['search']."'";
$comment= "select COMMENTS,DATE from comments where DATE='".$_POST['search']."'";

$my_comments=mysql_query($comment,$con);
$mydata=mysql_query($sql,$con);

echo "<table width='100%' height='10%' border='1' cellspacing='0'>
<tr>
<th>DATE</th>
<th>JOBNAME</th>
<th>TIME</th>
<th>INITIALS</th>
<th>SYSTEM TIMESTAMP</th>
</tr>";

while($records = mysql_fetch_array($mydata))

{

echo "<tr>";
echo "<td>" . $records['DATE'] . "&nbsp;</td>";
echo "<td>" . $records['JOBNAME']. "&nbsp;</td>";
echo "<td>" . $records['TIME'] . "&nbsp;</td>";
echo "<td>" . $records['INITIALS'] . "&nbsp;</td>";
echo "<td>" . $records['TIMESTAMP'] . "&nbsp;</td></tr>";

}

$records_comments = mysql_fetch_array($my_comments);


echo "<tr>";
echo '<td >';
echo "<h4>COMMENTS</h4>";
echo '</td><td colspan="2" >';
echo $records_comments['COMMENTS'];
echo '</td></tr>';

echo "</table>";

echo "<br>";
echo "<b> Generate Report </b>";
echo "<br>";
echo "<center>";
echo "<input type='submit' name='csv' value='CSV Report'>";
}

if(isset($_POST['csv']))

{
$filename = 'uploads/'.strtotime("now").'.csv';
$fp=fopen($filename,"w");
$selectcondition = "SELECT ID,DATE,JOBNAME,TIME,INITIALS FROM sample where DATE='".$_POST['search']."'";
$mydata=mysql_query($selectcondition,$con);


$row=mysql_fetch_assoc($mydata);

$seperator="";
$comma="";

foreach($row as $name => $value)

{

$seperator .= $comma . '' .str_replace('','""',$name);
$comma = ",";

}

$seperator .= "\n";

fputs($fp,$seperator);

mysql_data_seek($mydata,0);
while($row=mysql_fetch_assoc($mydata))

{
$seperator="";
$comma="";

foreach($row as $name => $value)

{

$seperator .= $comma . '' .str_replace('','""',$value);
$comma = ",";

}

$seperator .= "\n";
//echo $seperator;

fputs($fp,$seperator);
}
fclose($fp);

}

}

?>
</form>
</body>
</html>
Gamers
New php-forum User
New php-forum User
 
Posts: 48
Joined: Mon Jun 11, 2012 9:13 am

Re: Why my second isset function is not working..

Postby Gamers » Tue Oct 30, 2012 9:43 am

when i remove second isset function which i used for csv my code works fine but i want to export file after user click on this button .
Gamers
New php-forum User
New php-forum User
 
Posts: 48
Joined: Mon Jun 11, 2012 9:13 am


Return to mySQL & php coding

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.