Jump to content

emilyfrazier

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

emilyfrazier's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Sorry I took a little while to respond...I thought I had been given up on! Thanks for sticking with me. Since my full code is hundreds of lines, I will just include the pertinent areas. First, here is the code that gets printed out when I choose the select option for "Export File". This gets printed in the browser directly; does not prompt for download: [code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html  xmlns="http://www.w3.org/1999/xhtml"> <head> <title>CMD Members</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="../schedule/style.css" rel="stylesheet" type="text/css"> <script language="javascript"> function doSelect( obj ){ var frm = obj.form; var val = obj.value; // alert( val ); if( val == "reset" ){ frm.reset(); } else{ frm.submit(); } } function checkField( id ){ if( document.getElementById && document.getElementById(id) ){ obj = document.getElementById(id); if( obj.checked ){ obj.checked = false; } else{ obj.checked = true; } } } <!-- function MM_openBrWindow(theURL,winName,features) { //v2.0   window.open(theURL,winName,features); } </script> Id, First Name, Last Name, Organization, Email Address, Package, Pay By, Date Modified, Status 1,Emily,lastnamehere,org,emily@email.org,IND25,chk,2006-11-03,Deactivated[/code] So, in the actual page, here is what I have that is pertinent:[code]<?php require_once( "../schedule/config.php"); $listAction = ( isset( $_POST["resultsAction"] ) && $_POST["resultsAction"] != "")?$_POST["resultsAction"]:false; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html  xmlns="http://www.w3.org/1999/xhtml"> <head> <title>CMD Members</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="../schedule/style.css" rel="stylesheet" type="text/css"> <script language="javascript"> function doSelect( obj ){ var frm = obj.form; var val = obj.value; // alert( val ); if( val == "reset" ){ frm.reset(); } else{ frm.submit(); } } function checkField( id ){ if( document.getElementById && document.getElementById(id) ){ obj = document.getElementById(id); if( obj.checked ){ obj.checked = false; } else{ obj.checked = true; } } } <!-- function MM_openBrWindow(theURL,winName,features) { //v2.0   window.open(theURL,winName,features); } </script> <?php $myAction = 'onClick="doSelect(this);"'; $date = date("Y-m-d"); $nextmonth = date('Ymd', mktime(0, 0, 0, date("m"), date("d")+30,  date("Y"))); $lastmonth = date('Ymd', mktime(0, 0, 0, date("m"), date("d")-30,  date("Y"))); if( $listAction && $listAction == "csv" ) { header("Content-type: text/plain"); $query = "SELECT * FROM members WHERE mbrID IN('" . implode("', '", $_POST['all']) . "')"; $results = mysql_query($query) or die(mysql_error()); echo "Id, First Name, Last Name, Organization, Email Address, Package, Pay By, Date Modified, Status\n"; while ($data = mysql_fetch_array($results, MYSQL_ASSOC)) { if ($data["status"] == '0') { $status = "Pending"; } else if ($data["status"] == '1') { $status = "Activated"; } else if ($data["status"] == '2') { $status = "Deactivated"; } echo $data['mbrID'] . "," . $data['fName'] . "," . $data['lName'] . "," . $data['org'] . "," . $data['email'] . "," . $data['mbr_pkg'] . "," . $data['payType'] . "," . $data['active_date'] . "," . $status . "\n"; } exit; } // End If $listAction == csv ?> </head> <body> <?php $sql = "SELECT * FROM members ORDER BY status"; $rval = mysql_query( $sql ); $records_found = mysql_num_rows ($rval); ?> <hr /> <form action="<?PHP echo $_SERVER['PHP_SELF']; ?>" name="members" method="post"> <div align="center"><span class="textbold">Records Found: <?php echo $records_found; ?><br><br></span></div> <table width="100%" align="center" border="0" cellspacing="0" cellpadding="4"> <tr> <td colspan="8" align="center"> <select name="resultsAction" id="resultsAction"> <option value="">:: SELECT ACTION HERE ::</option> <option value="csv" <?php echo $myAction; ?>>Export File</option> <option value="reset" <?php echo $myAction; ?>>Reset Check Boxes</option> </select><br><br> </td> </tr> <tr bgcolor="#CCCCCC" class="textbold"> <td>&nbsp;<br /> </td> <td>Id</td> <td>Name</td> <td>Organization</td> <td>Email</td> <td>Package</td> <td>Pay By</td> <td>Date Modified</td> <td>Status</td> <td width="1%">&nbsp;</td> </tr> <?php $row = '0'; while($data = mysql_fetch_assoc ($rval) ){ ++$row; $bColor = $row % 2 == 0?"#CCCCCC":"#E0E0E0"; $link = "member_detail.php?id=".$data["mbrID"]; $datemysql = date ( "Y m d H:i:s" , strtotime ( $data [ 'date_joined' ])); if($data["status"] == '0'){ ?> <tr class="red" style="background:<?php echo $bColor; ?>;"> <td><input tabindex="<?php echo $row; ?>" type="checkbox" name="title[]" id="<?php echo $data["mbrID"]; ?>" value="<?php echo $data["mbrID"]; ?>" /></td> <td><a href="<?php echo $link; ?>" target="_blank" class="red"><?php  if( $data["mbrID"] != "" ){ echo $data["mbrID"] ; }else{ echo "&nbsp;"; } ?></a></td> <td><a href="<?php echo $link; ?>" target="_blank" class="red"><?php  if( $data["fName"] && $data["fName"] != "" ){ echo $data["fName"] ." ". $data["lName"]; }else{ echo "&nbsp;"; } ?></a></td> <td><a href="<?php echo $link; ?>" target="_blank" class="red"><?php if( $data["org"] && $data["org"] != "" ){ echo $data["org"]; }else{ echo "-";}?></a></td> <td><a href="<?php echo $link; ?>" target="_blank" class="red"><?php if( $data["email"] && $data["email"] != "" ){ echo $data["email"];}else{echo "-";}?></a></td> <td><a href="<?php echo $link; ?>" target="_blank" class="red"><?php if($data["mbr_pkg"] && $data["mbr_pkg"] != "" ){echo $data["mbr_pkg"];}else{echo "&nbsp;";}?></a></td> <td><a href="<?php echo $link; ?>" target="_blank" class="red"><?php if($data["payType"] && $data["payType"] != "" ){echo strtoupper($data["payType"]);}else{echo "&nbsp;";}?></a></td> <td><a href="<?php echo $link; ?>" target="_blank" class="red"><?php if($data["active_date"] && $data["active_date"] != ""){echo $data["active_date"];}else{echo "&nbsp;";}?></a></td> <td><a href="<?php echo $link; ?>" target="_blank" class="red"><?php if($data["status"] == '1' ) {echo 'Activated';}elseif($data["status"] == '2'){echo 'Deactivated!';}else{echo 'Pending';}?></a></td> <td width="1%"><input type="hidden" tabindex="<?php echo $row;?>" name="all[]" id="<?php echo $data["mbrID"];?>" value="<?php echo $data["mbrID"];?>" /></td> </tr> <?php } // End If Status == 0 } // End While $data loop ?> </table> </body> </html>[/code] I also tried removing the if( $listAction && $listAction == "csv" ) area out of the head section and into the body, but this did not make any difference...Also, while I understand most of this code, I did not write the javascript function doSelect. I took this on from someone else who had written those functions using Radio boxes (which I then changed to a select box) and who I was collaborating with. So I am still a newbie; don't assume I know too too much! Thanks, Emily
  2. I get the same issue; with this it just prints the html page info, javascript calls, and all of the data for the csv file...it does not prompt me to download a file... Any other ideas? Thank you very much for your help emily
  3. Hi, Thanks for the help. The bad ?> tag was just a bad copying by me; sorry about that. So I tried all the options you gave with no luck. When I remove the attachement header and change it to plain text it just prints the code to my screen.Just to be sure I'm doing this right, here is the code I ended up with: [code]<?php if( $listAction && $listAction == "csv" ){  header("Content-type: text/plain"); print "Id, First Name, Last Name, Organization, Email Address, Package, Pay By, Date Modified, Status". "\n"; $row = 0; foreach($_POST["all"] as $value){ $sql = "SELECT mbrID, fName, lName, org, email, mbr_pkg, payType, active_date, status FROM members where mbrID = '".$value."'"; // die($sql); $rval = mysql_query($sql); while ($data = mysql_fetch_assoc ($rval) ) { ++$row; if($data["status"] == '0'){ $status = "Pending"; }elseif($data["status"] == '1'){ $status = "Activated"; }elseif($data["status"] == '2'){ $status = "Deactivated";} print $data["mbrID"] . ",".$data["fName"] . ",". $data["lName"].",".$data["org"] . ",".$data["email"]. ",".$data["mbr_pkg"]. ",".$data["payType"].",".$data["active_date"].",".$status."\n"; } } } ?>[/code] Thanks again for helping.
  4. I am trying to export a csv file. There is a data display list from mySQL, and based on a drop-down the user can select to export CSV file. When this is chosen, here is my code: [code] if( $listAction && $listAction == "csv" ){ ?> header("Content-type: text/x-csv"); header("Content-Disposition: attachment; filename=CMD_Members.csv"); print "Id, First Name, Last Name, Organization, Email Address, Package, Pay By, Date Modified, Status". "\n"; $row = 0; foreach($_POST["all"] as $value){ $sql = "SELECT mbrID, fName, lName, org, email, mbr_pkg, payType, active_date, status FROM members where mbrID = '".$value."'"; // die($sql); $rval = mysql_query($sql); while ($data = mysql_fetch_assoc ($rval) ) { ++$row; if($data["status"] == '0'){ $status = "Pending"; }elseif($data["status"] == '1'){ $status = "Activated"; }elseif($data["status"] == '2'){ $status = "Deactivated";} print $data["mbrID"] . ",".$data["fName"] . ",". $data["lName"].",".$data["org"] . ",".$data["email"]. ",".$data["mbr_pkg"]. ",".$data["payType"].",".$data["active_date"].",".$status."\n"; } } }[/code] Where the $_POST["all"] is referring to all of the records in the list. So when I do this, the file exports, opens in Excel with an error about my style sheet. It then brings in ALL of the source code into a small box at the top of the page, and then formats my results like they look in the browser display. Can you tell me what I am doing wrong? Thanks, Emily
  5. Sorry, my mac didn't grab all that I thought it did. The code above is now correctly showing what I have. thanks!
  6. Hmm. Just tried that, but it didn't change anything. Am still getting the same errors. Here is my code:[code] <?php function getRandomImages($count = 1){ global $randomImages; srand((float) microtime() * 10000000); $ret = array(); $keys = array_rand($randomImages, $count); foreach( $keys as $index ){ array_push( $ret, $randomImages[$index] ); } return  $ret; } $randomImages = array(); function addRandomImage( $img = false ) { if( $img ){ global $randomImages; array_push( $randomImages, $img ); }} for( $i=1; $i<41; $i++ ){ addRandomImage( "../../../images/random_".sprintf("%02d", $i).".jpg" ); } ?> <table border="0" cellpadding="0" cellspacing="0" id="header">   <tr>         <?php $randomImages = getRandomImages(5); $first = true; foreach( $randomImages as $image ){ ?> <?php if( $first ){ $first=false; } else{ ?><td width="16"> <img src="../../../images/randompic_divider.gif" width="16" height="52"></td><?php } ?>     <td width="52"><img src="<?php echo $image; ?>" width="52" height="52"></td>    <?php } ?>[/code] Thanks for helping! Emily
  7. You can see this error here: http://www.retn.org/drupal/graduations I am really confused on this one, so if you can offer me any futher guidance I would greatly appreciate it! Thanks, Emily
  8. Maybe I am not understanding, but I believe I declared $randomImages both in the first and second functions. I declared the array in between the functions. ... I thought making it global would take care of the issue? Thanks for helping, Emily
  9. Hi, I am getting an error about array push, but I've declared my global variables. The error I get is: [color=red]warning: array_push() [function.array-push]: First argument should be an array in /home/retnkes9/public_html/drupal/themes/retn/page.tpl.php on line 18.[/color] Here is my code: [code]<?php function getRandomImages($count = 1){ global $randomImages; srand((float) microtime() * 10000000); $ret = array(); global $ret; $keys = array_rand($randomImages, $count); foreach( $keys as $index ){ array_push( $ret, $randomImages[$index] ); } return  $ret; } $randomImages = array(); function addRandomImage( $img = false ) { if( $img ){ global $randomImages; array_push( $randomImages, $img ); }} for( $i=1; $i<41; $i++ ){ addRandomImage( "../../../images/random_".sprintf("%02d", $i).".jpg" ); } ?> <table border="0" cellpadding="0" cellspacing="0" id="header">   <tr>       <?php $randomImages = getRandomImages(5); $first = true; foreach( $randomImages as $image ){ ?> <?php if( $first ){ $first=false; } else{ ?><td width="16"> <img src="../../../images/randompic_divider.gif" width="16" height="52"></td><?php } ?>     <td width="52"><img src="<?php echo $image; ?>" width="52" height="52"></td>    <?php } ?>     [/code] I would really appreciate any help on this in advance. It's really messing with me! Thanks, Emily
  10. I got it working using this:[code] $datemysqlyr = date ( "Y m d H:i:s" , strtotime ( $data [ 'date_joined' ])  + (365 * 24 *60 * 60)); [/code] Thanks very much for your help!! eef
  11. Thanks so much for the help...it doesn't work quite right. It is taking today's date if I use this code. I tried: $yr = date('Y-m-d H:i:s', time($data['date_joined']) + (365 * 24 *60 * 60)); And it gives me today's date a year from now...I need it to take a year from now from the 'date_joined' field...thanks again eef
  12. Hi all, I am still fairly new to PHP and mySQL. I have read all the tutorials on dates, yet I'm still not seeing the light today. So I have a field in my database called 'date_joined' that holds a timestamp when a users signs up for membership. I need to make a report that tells me all the memberships that will expire within the next 30 days (memberships are for 1 year). Is there a way to take my field and use mktime to add 1 year to it? I assume it's possible through a function that breaks up the date and then subs them in to a mktime string, but I was wondering if there is an easier way around it? I would really appreciate any help in advance. Thanks so much, eef
  13. Thanks, Ken...All works well now! Emily
  14. Hi all, I am struggling here. I am having problems with forming the array I want. The below code gives me both $mat and $murl as keys in my array $materials. What I really want to do is the create the array $materials and then have the keys be $mat and the values be $murl. The foreach is what is confusing me. I can't seem to push onto the array unless I'm within the loop. The code is below but I will also explain here with subsitute variable values. So for every $_POST["material"] there are a few values: for example "Goat", "Fish", "Bird"....then for each $murl there is a bunch of those to0: for example "goat.html", "fish.html", "bird.html". So I want them to be key value pairs such as "Goat" => "goat.html". Here is the code: [code] $materials = array(); foreach($_POST["material"] as $mat){ array_push($materials, $mat); } foreach($_POST["murl"] as $murl){ array_push($materials, $murl); } foreach ($materials as $key => $value){ print $key . ": " . $value . "<br>"; } [/code] Greatly appreciate your help in advance! Thanks, Emily
  15. Hi, This is a mySQL / php question. Thanks in advance for anyone who can help me with this; I am very close and assume my loop is in the wrong place but just can't quite get it. What I want is to have two text boxes created; one for the $u_data["url"] and another for the u_data["material"]. I need them to stay connected. So I want an array that holds a $key of $u_data["url"] and a $value of $u_data["material"]. Then I want to create 8 text boxes, and if the above data exists, then populate the boxes with that data; otherwise leave them empty. I have done this and get redundancy of information or I only get the number of boxes for the number of filled variables. HERE'S THE CODE: <?php $url_sql = "SELECT a.title, b.title, b.url, b.material FROM mprogram_library AS a LEFT JOIN web_url AS b ON (a.title = b.title) WHERE a.title = '".$id."'"; $url_rval = mysql_query ( $url_sql ); $rows = mysql_num_rows ( $url_rval ); $url_data = array(); while ( $u_data = mysql_fetch_assoc ( $url_rval ) ) { $url_data[sizeof( $url_data )] = $u_data["url"]; } for($i=0;$i<8;$i++){ ?> <input size="20" type="text" name="web_url[<?php echo $i; ?>]" id="web_url[<?php echo $i; ?>]" value="<?php echo isset( $url_data[$i] )?$url_data[$i]:""; ?>"> <?php } // End For ?> Thanks again if you can help me...Emily
×
×
  • 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.