maydhyam commented: R0bb0b was most helpful to me in my problem. Great guy! Great Work! +1
aaaaahaaaaaaaaah! :)
are the dates going in like 'yyyy-mm-dd'?
echo this:
"SELECT * FROM tsttbills where date >= '$sDate' and date <= '$eDate'"
This is a valid query, I just think the format of the dates may be incorrect or maybe you don't have any dates that fall between these dates. One of the two.
echo your query and post it.
The while loop that starts on line 68, replace it with
while($info = mysql_fetch_object($sql))
{
print_r($info);
echo "<br />";
}
and keep the header lines commented out. So we can see that the data is really there.
When you test it, and output it to the browser, do you see the rows or just the column headers?
could be "btnSubmit", but I can't see that making a difference because if isset($_POST) then count($_POST) > 0 = true
Yea, I did and there's still a blank page...
from the file testGCR.php....with the following piece of code....isn't there supposed to be an open and closed square brackets?
<? include("./gcrFunction.php"); if(count($_POST[]) == 0) { ?>
I never include them. You could also try an if(isset($_POST)) statement
move this line:
error_reporting(E_ALL ^ E_NOTICE);
on gcrFunction.php to just before the include statement on line 2 of testGCR.php
and comment out these lines.
$filename = $file."_".date("Y-m-d_H-i",time());
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=".$filename.".csv");
header("Pragma: no-cache");
header("Expires: 0");
first, get the "Web Developer" add on for firefox,
then go to http://www.i-spy360.com/spins/spin6/Spin360.html
and use the "Web Developer" option called "View Javascript" under the information tab. Then you can see how they do it.
ignore the google analytics portion
it actually looks relatively simple.
Oops, did you replace the top two lines in gcrFunction.php:
include("inc/functions.inc");
$conn = mysql_dbconn();
with your connection file
include('./connect.php');
I usually use tineMCE, which looks like it does exactly the same thing. If you want to do that I can help you with that, but chances are they have enough documentation and examples that you won't need my help.
UPDATE profile SET group = '2' WHERE uid = '2'
group is a keyword, use `group`
$checkdisabled is pluged into the checkbox so when you pull the query, if the column "disabled" is 1 then checked="checked" is added to the checkbox making it checked else that will be left out making it unchecked. I know a lot of people just put the word checked in the checkbox tag but checked="checked" is the correct xhtml syntax.
see if this works
added value to disabled checkbox
added check if disabled isset and = disabled
added if db disabled "checked='checked' "
<?php
session_start();
include 'config.php';
include 'opendb.php';
include("login.php");
echo '<link rel="stylesheet" type="text/css" href="profile.css">';
echo '<center><div id="page"><img src="images/profhead.gif" width="955" height="90" /></center>';
if($logged_in){
loggedgroup();
if($_SESSION[grptype] == 'Admin' or $_SESSION[grptype] == 'Superadmin' or $_SESSION[grptype2] == 'Admin' or $_SESSION[grptype2] == 'Superadmin'){
if ($_SESSION['uid'] == NULL){
echo '<META HTTP-EQUIV="refresh" content="0;URL=admin.php">';
}else{
displayLogin();
echo '<hr>';
if( isset($_GET['pg']) ) {
switch( $_GET['pg']) {
case 'view':
global $conn;
$sql = "SELECT * FROM `profiles` WHERE id='$_SESSION[uid]'";
$query = mysql_query($sql, $conn) or die(mysql_error());
$row = mysql_num_rows($query);
while ($row = mysql_fetch_array($query)) {
if($row['disabled'] == "1")
{
$checkdisabled = 'checked="checked" ';
}
else
{
$checkdisabled = '';
}
echo '<div id="vwprof"><center><h2>Personal Information</h2><table width="28%" align="center" background="images/trimmtext.gif" style="border-style:groove;border-color:navy;margin-top:12px;">
<tr><td width="50% align="left"><h3>Username:</h3></td><td width="50% align="right"><h4><input type="text" name="user" value="'.$row['username'].'" readonly></h4>
<tr><td width="50% align="left"><h3>Disabled:</h3></td><td width="50% align="right"><h4><input type="checkbox" ' . $checkdisabled . 'name="disabled" value="disabled" readonly></h4>';
echo '</td></tr><tr><td width="50% align="left"><h3>Name:</h3></td><td width="50% align="right"><h4><input type="text" name="name" value="'.$row['first_name'].' '.$row['last_name'].'" readonly></h4>';
echo '</td><tr><tr><td width="50% align="left"><h3>Group:</h3></td><td width="50% align="right"><h4><input type="text" name="group" value="'.$_SESSION['grpname'].'" readonly></h4>';
echo '</td><tr><tr><td width="50% align="left"><h3>Group 2:</h3></td><td width="50% align="right"><h4><input type="text" name="group2" value="'.$_SESSION['grp2name'].'" readonly></h4>';
echo '</td></tr><tr><td width="50% algin="left"><h3>Home Phone:</h3></td><td width="50% align="right"><h4><input type="text" name="phone" value="'. $row['phone'].'" readonly></h4></td></tr>';
echo '<tr><td width="50% algin="left"><h3>Alt Phone:</h3></td><td width="50% align="right"><h4><input type="text" name="altphone" value="'. $row['altphone'].'" readonly></h4></td></tr>';
echo '<tr><td width="50% algin="left"><h3>Alt Phone Type:</h3></td><td width="50% align="right"><h4><input type="text" name="altphn_title" value="'. $row['altphn_title'].'" readonly></h4></td></tr>';
echo '<tr><td width="50% algin="left"><h3>Email Address:</h3></td><td width="50% align="right"><h4><input type="text" name="email" value="'. $row['email'].'" readonly></h4></td></tr>
<tr align="left"><center><td><a href="adminprofile.php?pg=edit">Edit Personal Profile</a></td></center><td><a href="adminprofile.php?pg=systems">View System Profiles</a></td> <td align="right"></tr></table>
<h2>Physical Address</h2><table width="28%" align="center" background="images/trimmtext.gif" style="border-style:groove;border-color:navy;margin-top:12px;">
<tr><td …
moved the delete block to the top so the file is deleted before you fill the form with the current existing files. Included current url redirect to refresh after the post(just a personal preference) because I think is reflects a better experience for the user to not have to worry about reposting every time the user wants to refresh the page after a post. Changed the checkbox name to an array, and the script loops through all the checked items of the array.
<?php
$path = "test";
if(isset($_POST['file']) && is_array($_POST['file']))
{
foreach($_POST['file'] as $file)
{
unlink($path . "/" . $file) or die("Failed to delete file");
}
header("location: " . $_SERVER['REQUEST_URI']); //redirect after deleting files so the user can refresh without that resending post info message
}
?>
<form name="form1" method="post">
<?php
$path = "test";
$dir_handle = @opendir($path) or die("Unable to open folder");
while (false !== ($file = readdir($dir_handle))) {
if($file == "index.php")
continue;
if($file == ".")
continue;
if($file == "..")
continue;
echo "<input type='CHECKBOX' name='file[]' value='$file'>";
echo "<img src='$file' alt='$file'><br />";
}
closedir($dir_handle);
?>
<input type="submit" name="Delete" value="Delete">
</form>
the problem is that when you post a variable name that includes a ".", the "." is automatically replaced with an "_". You can see that by putting print_r($_POST);
at the top of your file.
I'm looking for a fix now.
this is funny
Your the only one on the list.
http://www.google.com/search?hl=en&q=telnet+%22-ERR+protocol+error+16%22&btnG=Google+Search
I'll keep my eyes open.
or something...
is "-ERR protocol error 16" the exact error?
close your while statement
few slight changes, was getting headers already sent error: fixed
that's probably what was messing with the excel parsing.
that's about the only thing though, nice script.
liked the way you used $head[] = mysql_field_name($sql, $i);
gonna have to try that.
testGCR.php
<?
include("./gcrFunction.php");
if(count($_POST) == 0)
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Test Document</title>
<script language="javascript" type="text/javascript" src="datetimepicker.js">
//Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
//Script featured on JavaScript Kit (http://www.javascriptkit.com)
//For this script, visit http://www.javascriptkit.com
</script>
</head>
<body>
<form method="post" target="_blank">
<table>
<tr>
<td width="747">
<p align="left"><span class="style4 style25 style28 style6">Generate Chargeback Report</span></p>
<p align="left"><span class="style21 style29 style5">The Chargeback Reporter works in 2 steps.</span></p>
</td>
</tr>
<tr><td><p> </p></td></tr>
<tr>
<td>
<table width="648" border="0" align="center" cellpadding="1" cellspacing="0" bordercolor="#FFFFFf">
<tr>
<td bgcolor="#99bebe" colspan="4">
<p align="left" class="style8 style7 style32"><strong>
<span class="style21 style33 style11">Step 1: Select Start and End Date</span></strong></p>
</td>
</tr>
<tr>
<td width="100" bgcolor="#99bebe" scope="row">
<div align="left" class="style8 style7 style31 style29 style13">
<div align="right"><strong>Start Date: </strong></div>
</div> </td>
<td width="220" bgcolor="#99bebe">
<input name="sDate" id="sDate" type="text" size="25">
<a href="javascript<b></b>:NewCal('sDate','ddmmyyyy')">
<img src="images/cal.gif" width="16" height="16" border="0" alt="Pick a Start Date">
</a> </td>
<td width="100" bgcolor="#99bebe" scope="row">
<div align="left" class="style8 style7 style31 style29 style13">
<div align="right"><strong>End Date: </strong></div>
</div> </td>
<td width="220" bgcolor="#99bebe">
<input name="eDate" id="eDate" type="text" size="25">
<a href="javascript<b></b>:NewCal('eDate','ddmmyyyy')">
<img src="images/cal.gif" width="16" height="16" border="0" alt="Pick an End Date">
</a> </td>
</tr>
<tr>
<td bgcolor="#99bebe" …
Just a tip to help you bypass the frustration:
Usually when I am exporting to csv, excel, pdf or anything, I always have two different modes, production mode and development mode.
In production mode, of course I am outputting the desired output like normal. In development mode I am just outputting straight to the browser or textarea or whatever allows me to analyze my output the easiest. I usually have this set in a variable at the top.
This allows you to analyze the actual behavior of your code without involving any more variables then necessary at the time.
Anyway, Post your code and I'll look at it.
if your talking about the function time() and a unix timestamp 1 = 1 second
Try this
<strong>Update multiple rows in mysql</strong><br>
<?php
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="test_mysql"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
// Count table rows
$count=mysql_num_rows($result);
?>
<table width="500" border="0" cellspacing="1" cellpadding="0">
<form name="form1" method="post" action="<? echo $_SERVER['REQUEST_URI']; ?>">
<tr>
<td>
<table width="500" border="0" cellspacing="1" cellpadding="0">
<tr>
<td align="center"><strong>Id</strong></td>
<td align="center"><strong>Name</strong></td>
<td align="center"><strong>Lastname</strong></td>
<td align="center"><strong>Email</strong></td>
<td align="center"><strong>On / Off</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result))
{
?>
<tr>
<td align="center"><input type="hidden" name="id[]" value="<? echo $rows['id']; ?>" /><? echo $rows['id']; ?></td>
<td align="center"><input name="name<? echo $rows['id']; ?>" type="text" id="name" value="<? echo $rows['name']; ?>"></td>
<td align="center"><input name="lastname<? echo $rows['id']; ?>" type="text" id="lastname" value="<? echo $rows['lastname']; ?>"></td>
<td align="center"><input name="email<? echo $rows['id']; ?>" type="text" id="email" value="<? echo $rows['email']; ?>"></td>
<td align="center"><input name="ONOFF<? echo $rows['id']; ?>" type="checkbox" id="ONOFF" value="1"
<?php if ($rows['ONOFF'] ==1) { echo "checked";} else {} ?>
></td>
</tr>
<?php
}
?>
<tr>
<td colspan="4" align="center"><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</td>
</tr>
</form>
</table>
<?php
// Check if button name "Submit" is active, do this
if($Submit)
{
foreach($_POST['id'] as $id)
{
$sql1="UPDATE ".$tbl_name." SET name='".$_POST["name".$id]."', lastname='".$_POST["lastname".$id]."', email='".$_POST["email".$id]."', ONOFF='".$_POST["ONOFF".$id]."' WHERE id='".$id."'";
$result1=mysql_query($sql1);
}
}
if($result1){
header("location:update_multiple.php");
}
mysql_close();
?>
You were looping through with a counter and using the loopnumber as your id, this will only work if you are absolutely positive that your ids are sequential, looks like you are using register globals I think. I've …
adjusted the onmouseout function
<td background="images/button_main.gif" class="hand" onMouseOver="getCity('getButtons.php?city=<?php echo $city;?>');" onMouseOut="setTimeout('getCity(\'getButtons.php?city=<?php echo $original_city;?>\')', 3000);" onClick="">BUTTON</span></td>
This is how you get the length of a string.
var stringlen = stringvarname.length;
BTW: its all html when it hits the browser
I tested it and it works fine for me, so I'm thinking it may be an image formatting problem on top of the javascript error.
In javascript we can swap only jpg images? Then what about the gif images. Please help me.
By answering my first post so the second post will be solved automatically.
It's just plain text either way, image type has nothing to do with it. I mean it's not like you are reconstructing the images, your just swapping text.
var rowItem = document.createElement("<input type=text id=['up' + i]>");
try this:
var inputid = "up" + i;
var rowItem = document.createElement('<input type="text" id="' + inputid + '">');
and according to what I've read here, you need to provide valid html for ie, yet that will throw an error in ff so you will have to check the browser type, refer here http://www.byteclub.net/wiki/index.php?title=Javascript_createElement
Think I made just one adjustment and it works now.
<html>
<head>
<title>swapimage</title>
</head>
<script>
var arr=["img/wysiwyg_buttons/bold.gif","img/wysiwyg_buttons/italic.gif","img/wysiwyg_buttons/strike.gif"];
i=0;
function swap()
{
document.images[0].src=arr[i];
i++;
if(i==3)
i=0;
setTimeOut("swap()",5000);
}
</script>
<body bgcolor="white">
<marquee behaviour="alternate" direction="left" onClick="swap();"><img src="img/wysiwyg_buttons/link.gif" >
</marquee>
</marquee>
</body>
</html>
After I moved the onclick event, it worked fine.
$test="<table border=1><tr><td>Cell 1</td><td>Cell 2</td></tr></table>";
Wow! That really works! I've always done just plain csv files, I didn't know you could use html. You've made my day.
<?php
$file="test.xls";
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$file");
?>
<table cellpadding="0" cellspacing="0">
<tr>
<td>cell one</td>
<td>cell two</td>
<td>cell three</td>
<td>cell four</td>
</tr>
<tr>
<td colspan="4" align="center"><b>cell one</b></td>
</tr>
<tr>
<td>cell one</td>
<td>cell two</td>
<td>cell three</td>
<td>cell four</td>
</tr>
</table>
Freaking cool man! Thx.
:) :) :) :) :) :) :) :) :)
I guess you could also do that in the database too. Have like an faq_activity table that updates every time a user views an faq and then you could just pull the 4 most recent for that user. You'd have to keep it cleaned up else it will get fairly large, but it could be as simple as a faq_activitypk, faqpk and userpk.
$query = "select distinct faqpk, userpk from faq_activity where userpk = " . $userpk . " order by faq_activitypk desc limit 4";
something like that.
All the questions that you've viewed up to this point?
previous viewd question
I don't understand. Can you explain further?
faq.php
<a href="faqview.php?faqpk=12">FAQ Title</a>
faqview.php
<?
if(!is_numeric($_GET['faqpk']))
{
header("location: faq.php");
exit();
}
$faqpk = $_GET['faqpk'];
$query = "select title, description from faq where faqpk = " . $faqpk;
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
echo "<p>".$row["title"]."</p>";
echo "<p>".$row["description"]."</p>";
}
?>
I am using some little cookies, where I store a user information for example: nickname and password.
And try sessions also,if you want to store more user data like nick name etc...
Exactly, I'm not too excited about my password being stored in a cookie, maybe an md5 of my password, but I even get nervous about that. I think its just bad practice.
maybe this?
<?php
$output=<<<HEREDOC
<div>
HEREDOC;
if($i==2) {
$output.=<<<HEREDOC
$i is 2
</div>
HEREDOC;
}
echo $output;
You can't stop someone from creating multiple accounts unless you block entire IPs, which you don't want to do because most IPs are shared. The only thing you can do is keep people from creating accounts with information that has already been used, for ex. email address, user name, nick name etc...
If you actually want to delete the cookie at the time the user clicks your log out button, use this:
setcookie("user", "Current User", time()-3600);
You're actually modifying the expiration time to be negative instead of positive.
Fixed a couple of bugs
1. wouldn't display last page number, now it does
2. pages started at zero, now they start at one
3. on last page next and last were still displayed, fixed.
<?
$conn = mysql_connect("localhost", "test", "test");
if(!$conn)
{
echo "could not connect to db<br />";
}
mysql_select_db("mydev", $conn) or die("could not select db<br />");
$rowsperpage = 100;
$paginatorwidth = 5;
$start = isset($_GET['start'])?$_GET['start'] + 0:0;
$curpage = round($start / $rowsperpage);
$start = $curpage * $rowsperpage;
$_GET['search'] = isset($_GET['search'])?$_GET['search']:"test"; // for development
$query = "select librarypk, bookname from library where bookname like('".$_GET['search']."%') LIMIT ".$start.",".$rowsperpage;
$result = mysql_query($query);
$total = mysql_num_rows($result);
$query = "select count(librarypk) as total from library where bookname like('".$_GET['search']."%')";
$countresult = mysql_query($query);
$counttotal = mysql_result($countresult, 0, "total");
$totalpages = round($counttotal / $rowsperpage);
if($totalpages * $rowsperpage > $counttotal)
{
$totalpages -= 1;
}
$paginatorlinks = array();
$paginatorlinks[] = '<td><a class="inactive" href="'.$_SERVER['PHP_SELF'].'?start=0&search='.$_GET['search'].'">First</a></td>'."\n";
$paginatorlinks[] = '<td><a class="inactive" href="'.$_SERVER['PHP_SELF'].'?start='.($start - $rowsperpage).'&search='.$_GET['search'].'"><< Previous</a></td>'."\n";
$loopcontrol = ($counttotal / $totalpages > $totalpages)?$totalpages + 1:$totalpages;
for($i = 0; $i < $loopcontrol; $i++)
{
if($i >= $curpage - $paginatorwidth && $i < $curpage + $paginatorwidth)
{
if($i == $curpage)
{
$class = "class='active'";
}
else
{
$class = "class='inactive'";
}
$pagedisplay = $i + 1;
$paginatorlinks[] = '<td style="width:20px;"><a '.$class.' href="'.$_SERVER['PHP_SELF'].'?start='.$i * $rowsperpage.'&search='.$_GET['search'].'">'.$pagedisplay.'</a></td>'."\n";
}
}
if($curpage < $totalpages)
{
$paginatorlinks[] = '<td><a class="inactive" href="'.$_SERVER['PHP_SELF'].'?start='.($start + $rowsperpage).'&search='.$_GET['search'].'">Next >></a></td>'."\n";
$paginatorlinks[] = '<td><a class="inactive" href="'.$_SERVER['PHP_SELF'].'?start='.($totalpages * $rowsperpage).'&search='.$_GET['search'].'">Last</a></td>'."\n";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> …
edited the code above to fix bug in the last page variable because round may go up or down. So I included a little block at line 28 to test the total pages * amount per page and see if it was greater than the total, and if so subtract 1 from total pages. And you probably want to do some type of validation of the inputs before querying the database.
Dude, that is a lot of code for pagination and with no code tags. Here is a simple pagination script, try incorporating that.
<?
$conn = mysql_connect("localhost", "test", "test");
if(!$conn)
{
echo "could not connect to db<br />";
}
mysql_select_db("mydev", $conn) or die("could not select db<br />");
$rowsperpage = 100;
$paginatorwidth = 5;
$start = isset($_GET['start'])?$_GET['start'] + 0:0;
$curpage = round($start / $rowsperpage);
$start = $curpage * $rowsperpage;
$_GET['search'] = isset($_GET['search'])?$_GET['search']:"test"; // for development
$query = "select librarypk, bookname from library where bookname like('".$_GET['search']."%') LIMIT ".$start.",".$rowsperpage;
$result = mysql_query($query);
$total = mysql_num_rows($result);
$query = "select count(librarypk) as total from library where bookname like('".$_GET['search']."%')";
$countresult = mysql_query($query);
$counttotal = mysql_result($countresult, 0, "total");
$totalpages = round($counttotal / $rowsperpage);
if($totalpages * $rowsperpage > $counttotal)
{
$totalpages -= 1;
}
$paginatorlinks = array();
$paginatorlinks[] = '<td><a class="inactive" href="'.$_SERVER['PHP_SELF'].'?start=0&search='.$_GET['search'].'">First</a></td>'."\n";
$paginatorlinks[] = '<td><a class="inactive" href="'.$_SERVER['PHP_SELF'].'?start='.($start - $rowsperpage).'&search='.$_GET['search'].'"><< Previous</a></td>'."\n";
for($i = 0; $i < $totalpages; $i++)
{
if($i >= $curpage - $paginatorwidth && $i < $curpage + $paginatorwidth)
{
if($i == $curpage)
{
$class = "class='active'";
}
else
{
$class = "class='inactive'";
}
$paginatorlinks[] = '<td style="width:20px;"><a '.$class.' href="'.$_SERVER['PHP_SELF'].'?start='.$i * $rowsperpage.'&search='.$_GET['search'].'">'.$i.'</a></td>'."\n";
}
}
$paginatorlinks[] = '<td><a class="inactive" href="'.$_SERVER['PHP_SELF'].'?start='.($start + $rowsperpage).'&search='.$_GET['search'].'">Next >></a></td>'."\n";
$paginatorlinks[] = '<td><a class="inactive" href="'.$_SERVER['PHP_SELF'].'?start='.($totalpages * $rowsperpage - $rowsperpage).'&search='.$_GET['search'].'">Last</a></td>'."\n";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
a.inactive{color:blue;}
a.active{color:#FF0000; font-weight:bold;}
</style>
</head>
<body>
<table cellpadding="0" cellspacing="0">
<tr>
<?
foreach($paginatorlinks as $pagelink)
{
?>
<? echo $pagelink; ?><td> </td>
<?
} …
I believe all of the below are open source:
http://www.fpdf.org/
http://www.gnuvox.com/pdf4php/
http://www.ros.co.nz/pdf/
I would probably go with www.fpdf.org myself, and I believe there is quite a bit of documentation on fpdf in comparison to the other two.
Ya you are definitely going to want to generate these on the fly, that is unless you want to create thousands of pdfs manually.
Run this on your server to see if pdflib is installed.
if(!extension_loaded("pdf"))
{
echo "pdflib is not installed";
}
You will want this installed since it is the most popular and the most documented pdf extension. I have heard that there are other extensions you can use instead, but this is by far the most widely used.
Do the pdfs already exist or are they actually going to dynamically generated?
Here are some examples for textboxes, checkboxes, radio buttons and select drop downs:
<?
session_start();
//collect text box values
$txtFname = isset($_POST['txtFname'])?$_POST['txtFname']:"";
$txtLname = isset($_POST['txtLname'])?$_POST['txtLname']:"";
$txtMI = isset($_POST['txtMI'])?$_POST['txtMI']:"";
//values for ages select element
$ages = array();
$ages[] = "1 - 10";
$ages[] = "11 - 20";
$ages[] = "21 - 30";
$ages[] = "31 - 40";
$ages[] = "41 - 50";
$ages[] = "51 - 60";
$ages[] = "61 - 70";
$ages[] = "71 - 80";
$ages[] = "81 - 90";
$ages[] = "91 - 100";
//selected value for ages
$selAge = isset($_POST['selAge'])?$_POST['selAge']:"";
//build and set selected values for chk boxes interests
$interests = array();
$interests["IT"] = (isset($_POST['chkInterests']) && in_array("IT", $_POST['chkInterests']))?' checked="checked"':"";
$interests["Snowboarding"] = (isset($_POST['chkInterests']) && in_array("Snowboarding", $_POST['chkInterests']))?' checked="checked"':"";
$interests["Hockey"] = (isset($_POST['chkInterests']) && in_array("Hockey", $_POST['chkInterests']))?' checked="checked"':"";
$interests["Football"] = (isset($_POST['chkInterests']) && in_array("Football", $_POST['chkInterests']))?' checked="checked"':"";
//build and set selected values for radio buttons Gender
$rdoGender = array();
$rdoGender["Male"] = (isset($_POST['rdoGender']) && $_POST['rdoGender'] == "Male")?' checked="checked"':"";
$rdoGender["Female"] = (isset($_POST['rdoGender']) && $_POST['rdoGender'] == "Female")?' checked="checked"':"";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body onload="startTime();">
<form method="post" action="<? echo $_SERVER['REQUEST_URI']; ?>">
First Name: <input type="text" name="txtFname" value="<? echo $txtFname; ?>" /><br />
Last Name: <input type="text" name="txtLname" value="<? echo $txtLname; ?>" /><br />
MI: <input type="text" name="txtMI" value="<? echo $txtMI; ?>" /><br /><br />
Age:<br />
<select name="selAge">
<?
foreach($ages as $age)
{
?>
<option <? if($age == $selAge) echo ' selected="selected"'; ?> value="<? echo $age; ?>"><? echo …
This will give you the basic functionality:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript" type="text/javascript">
var timerid = 0;
var images = new Array( "image1.jpg",
"image2.jpg",
"image3.jpg");
var countimages = 0;
function startTime()
{
if(timerid)
{
timerid = 0;
}
var tDate = new Date();
if(countimages == images.length)
{
countimages = 0;
}
if(tDate.getSeconds() % 5 == 0)
{
document.getElementById("img1").src = images[countimages];
}
countimages++;
timerid = setTimeout("startTime()", 1000);
}
</script>
</head>
<body onload="startTime();">
<img id="img1" src="image3.jpg" />
</body>
</html>
Break the process into small segments.
and use google for each step, you can literally copy the words that I have put down and use them in the google search textbox.
How can I apply this to the file attached
???
Thank you
Copy this function to your php file if fputcsv() is undefined: http://us.php.net/manual/en/function.fputcsv.php#77866
and then put the following code on the same page:
$contents = file("dtifeed.txt"); //your path/file with read permission
$handle = fopen('file.csv'/*some other path/file with write permission*/, 'w');
foreach($contents as $line)
{
fputcsv($handle, explode("\t", $line));
}
fclose($handle);
You'll probably find all the documentation right here
http://us.php.net/manual/en/function.fputcsv.php