Jump to content

dmikester1

Members
  • Posts

    107
  • Joined

  • Last visited

Everything posted by dmikester1

  1. That makes sense. However there is still a problem. There can be multiple checkboxes with the same value(athlete ID). Only when you compare them against the event IDs do you get a unique instance. So I need to get the array of checked checkboxes matched up with their associated event IDs passed over to the other side. Thanks Mike
  2. $result = mysql_query($query); while($row = msyql_assoc_array($result) { echo "Name: " . $row['fullname']; echo "Gender: " . $row['gender']; etc.... } Something like that should get you started. Mike
  3. I've been trying to figure this problem out for a few hours and I'm getting pretty frustrated. I have a form with a bunch of checkboxes associated with a given athlete in a given event. All the checkboxes are initially checked. If any get unchecked and then the submit button is hit, it is supposed to delete the entry in the database for that athlete for that given event. I'm to pass over an associate array containing the athlete ID connected with an event ID in a session var usin. But I'm trying to figure out how to get a similar array passed over for the checkboxes that are or are not checked. I can grab the athlete IDs that are associated with the checkboxes that are checked. But I also need the event IDs to be matched up with the athlete IDs on the other side. I've tried posting an associative relay and had no luck. Can someone help me out? Thanks Mike
  4. I'm really struggling here. I need to ouput a last name to a input text box. The name has a single quote in it. I can only get the text before the quote to output. Here is my php code: echo "<div class='fifteen'>$i. First name:</div><input type='text' value='$firstName' id='$first' name='$first' size='12' /> Last name:$lastName <input type='text' value='$lastName' name='$last' id='$last' size='12' /> Year: "; The $lastName variable has a single quote in it. I've tried addslashes, stripslashes, and mysql_real_escape_string alone and in combination all to no avail. Can someone help me? Thanks. Mike
  5. Sure. Ditch the '?' and you don't need a slash in front of the URL. Make sure your first line of code on both pages is: <?php session_start(); ?> or sessions won't work. The other way to would be to pass the email address via POST. http://www.tizag.com/phpT/examples/formex.php Mike
  6. Is this a website you are creating? Or is this just on your local computer?
  7. I don't know if you know any JQuery, but JQuery's Datepicker is wonderful for this sort of thing. And you can of course change the format of the date in the options. Check it out. http://jqueryui.com/demos/datepicker/ Mike
  8. Your form is not submitting to anywhere. You need to put something in the action I believe. If you want to submit to the same page use: action="<?php echo $_SERVER['PHP_SELF']; ?>"
  9. OK, never mind, I figured it out myself now.
  10. Well, you need to get today's date using PHP's Date function. http://php.net/manual/en/function.date.php Then do a "select issue from database" making sure the two dates are in the same format and compare for equality. Mike
  11. Is issue a "date" in your database? Are you storing a date in the database for each issue?
  12. I have a page that dynamically lists some names from my database. Each of these names is a link that will take you to the same "show report" page. However I need to pass along wth id of the person when the link is clicked so the next page knows which report to grab. I don't want to use the GET method. Can someone help me out? Thanks Mike
  13. Sweet, I figured it out! My included login.php file had some extra lines and tabs/spaces in it. I cleaned that up and it works like a charm! Mike
  14. Hah, OK that was really dumb of me. Thank you very much oni-kun. Now, I'm also having a problem with a blank line with what looks like 2 tabs getting added at the very beginning. Do you know why that is? Thanks Mike
  15. Here is some code I whipped up for you. You can use this with oni-kun's code. Mike <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>Hi-score lookup</title> </head> <body> <html> <?php if(isset($_POST['username'])) { $user = $_POST['username']; $homepage = file_get_contents('http://hiscore.runescape.com/index_lite.ws?player=' . $user); echo $homepage; } else { ?> <form id="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> Enter your username: <input type="text" id="username" name="username" /> <input type="submit" value="Submit" /> </form> <?php } ?> </html> </body>
  16. I'm trying to create a text file dynamically to be downloaded in PHP. For some reason there is a blank line getting added to the beginning and end of my text file. Can anyone figure out why this is happening? Thanks Mike <?php $filename = "semicolon-delimited.txt"; // Make sure we can't download files above the current directory location. if((strstr($filename, "\.\.")) != false) { die("I'm sorry, you may not download that file."); } $file = str_replace("..", "", $filename); // Extract the type of file which will be sent to the browser as a header $type = filetype($file); // Send file headers header("Content-type: $type"); header("Content-Disposition: attachment;filename=$filename"); header("Content-Transfer-Encoding: ascii"); header('Pragma: no-cache'); header('Expires: 0'); $ourFileHandle = fopen($file, 'w') or die("can't open file"); for($i = 0; $i < 5; $i++) { $stringData = "E;$i;a line;a phrase;"; //. $row['performance'] . ";" . $row['lastName'] . ";" . $row['firstName'] . ";"; $stringData = trim($stringData); fwrite($ourFileHandle, "$stringData\r\n"); } $file = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "", $file); fclose($ourFileHandle); // Send the file contents. set_time_limit(0); readfile(trim($file)); ?>
  17. I have a directory/file listing on my site. I can click "edit" next to each of the files to pop up a basic file editor which loads in the text of the file using file_get_contents($newFile); Now, I have a save button at the bottom and when I click it, it saves the edited text to the current file being worked on. Then it pops up a message at the bottom saying "file saved" with javascript. The problem is, when I post, it reloads the window loading in the unedited file contents. Here is my form code: <form method="post" action="<?php echo $_SERVER['PHP_SELF']."?dir=".$_GET['dir']."&file=".$_GET['file'];?>"> <div><textarea rows="25" cols="70" style="border: 1px solid #666666;" id="updatedfile" name="updatedfile"> <?php $filedir = $_GET['dir']; if($filedir == "") { $filedir = "."; } if(is_readable($filedir)) //check that the get "value" is readable { $newFile = $_GET['file']; if ($newFile == "ht") { $newFile = ".htaccess"; $fileText = file_get_contents($newFile); echo $fileText; ?></textarea><br /></div> <div class = "center">File will be saved as: <strong>.htaccess</strong> <?php } else if($newFile == "") { ?></textarea></div> <div class = "center">Name of file: <input type="text" name="filename" id="filename"> <?php } else { $fileText = file_get_contents($newFile); echo $fileText; ?></textarea><br /></div> <div class = "center">File will be saved as: <strong><?php echo $newFile ?></strong> <?php } ?> <br /><br /></div> <div id="hidden"></div> <div><input type="submit" name="save" id="save" value="Save Changes" onclick="return checkIfEmpty('filename')"></div> <?php if (isset($_POST['save'])) { //if the "save" button was clicked if($newFile == "") { $file = $_POST['filename']; } else { $file = $newFile; } $file = $cwd.$file; $file2save = fopen($file, "w+"); if (is_writable($file)) { $data_to_save = $_POST["updatedfile"]; $data_to_save = eregi_replace("<END-TA-DO-NOT-EDIT>", "</textarea>", $data_to_save); if (fwrite($file2save,$data_to_save)) { ?><script type="text/javascript"> document.getElementById('updatedfile').focus(); </script> <?php echo "file saved!"; //Close file fclose($file2save); }else { //If write fails show failure page echo "file not saved!"; //Close file fclose($file2save); } }else { echo "not writable!"; } } } ?> </form> Thanks Mike
  18. It's a long one. Here is the code that generates a single line with the filename and edit link on it. <tr class="<?=$class;?>" id="file<?=$i;?>"><td><img src="images/<?=$icon;?>" alt="<?=$files[$i];?>" /></td><td id="<?=finame.$i;?>"><a href="<?=$fileurl;?>"><?=$thumb2;?><?=$filename;?></a></td><td class = "edit"><a href="#" onclick="javascript:popup(none)">edit</a></td><td><em><?=round(filesize($leadon.$files[$i])/1024);?>KB</em></td><td class="date"> <?=date ("M d Y h:i:s A", filemtime($leadon.$files[$i]));?><?=$thumb;?></td><td class="checkbox"><input type="checkbox" name="filebox<?=$i;?>" id="filebox<?=$i;?>" value="" onclick="highlightRow(this);" /></td></tr> Thanks Mike
  19. I have the edit link attached to a js function with "onclick". Here is that JS code: function popup(filename) { if(filename != "") { win = window.open('FileEditor.php?dir=<?=$_GET['dir']?>&file='+filename,'window','height=600, width=700,toolbar=no,directories=no, status=no, menubar=no,scrollbars=no,resizable=yes'); } else { win = window.open('FileEditor.php?dir=<?=$_GET['dir']?>&file=','window','height=600, width=700,toolbar=no,directories=no, status=no, menubar=no,scrollbars=no,resizable=yes'); } win.moveTo(100,100); return false; } Now, the filename is in php and I don't know how to pass it to the javascript.
  20. I have my site listing out a bunch of files, one per row. In each row there is an "edit" link next to each filename. Right now, when that link is clicked a new window pops up with a blank file editor. There is nothing in the content area. Can someone explain to me how to pass the contents of the file next to the "edit" clicked into that window. Thanks Mike
  21. Thanks Teng, I got it to pass the name of the file in the URL. Now how do I obtain that in the new window? Thanks Mike
  22. No, 'dir' is the folder name where I currently am when I click on the link. I have my app listing out all the files in the directory automatically and it sticks an "edit" link next to each filename. How can I pass the name of the file onto the FileEditor.php popup when I click "edit"?
  23. Well, i have the popup working. I just need to load the relevant content into it. Here is the line that pops up the file editor: win = window.open('FileEditor.php?dir=<?=$_GET['dir']?>','window','height=600, width=700,toolbar=no,directories=no, status=no, menubar=no,scrollbars=no,resizable=yes');
  24. I am trying to figure out how to get the content from a file loaded into a popped up window's content area when an "edit" link is clicked. The edit link will be right next to the name of the file in my directory listing app. Thanks Mike
×
×
  • 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.