Jump to content

TapeGun007

Members
  • Posts

    307
  • Joined

  • Last visited

Everything posted by TapeGun007

  1. After scouring the web, I came up with a perfect piece of really simple code. Here is the JavaScript: function autoComplete(field, select, property, forcematch){ var found = false; for(var i = 0; i < select.options.length; i++){ if(select.options[i][property].toUpperCase().indexOf(field.value.toUpperCase()) == 0){ found=true; break; } } if(found){ select.selectedIndex = i; }else{ select.selectedIndex = -1; } if(field.createTextRange){ if(forcematch && !found){ field.value=field.value.substring(0,field.value.length-1); return; } var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;"; if(cursorKeys.indexOf(event.keyCode+";") == -1){ var r1 = field.createTextRange(); var oldValue = r1.text; var newValue = found ? select.options[i][property] : oldValue; if(newValue != field.value){ field.value = newValue; var rNew = field.createTextRange(); rNew.moveStart('character', oldValue.length); rNew.select(); } } } } This example code works great! <HTML> <HEAD> <SCRIPT LANGUAGE="JavaScript" SRC="components/autocomplete.js"></SCRIPT> </HEAD> . . . <FORM> <B>Auto-Complete</B><BR> Start typing a name in the input box that matches a name in the drop-down...<BR> <INPUT TYPE="text" NAME="input1" VALUE="" ONKEYUP="autoComplete(this,this.form.options,'value',true)"> <SELECT NAME="options" onChange="this.form.input1.value=this.options[this.selectedIndex].value"> <OPTION VALUE="adam">adam <OPTION VALUE="george">george <OPTION VALUE="matt">matt <OPTION VALUE="bill">bill <OPTION VALUE="greg">greg <OPTION VALUE="bob">bob <OPTION VALUE="david">david <OPTION VALUE="ryan">ryan </SELECT> </FORM> However, when I try to modify the code and insert some PHP, this partially works. If I select something from the drop down list, it will autopopulate the INPUT box, but the INPUT box does not auto select the drop down list like the HTML example above does. I am making a call to include the Javascript in the <head></head> tags btw. <tr><td align="right">Which song does this belong to? </td> <td> <b>Search:</b><br> <INPUT TYPE="text" NAME="input1" VALUE="" ONKEYUP="autoComplete(this,this.form.options,'value',true)"> <SELECT NAME="options" onChange="this.form.input1.value=this.options[this.selectedIndex].value"> <?php $result = mysql_query("SELECT * FROM SongEntries ORDER BY SongTitle ASC"); while($row = @mysql_fetch_array($result)){ If (strlen($row['AlbumName'])<1){ echo "<OPTION VALUE='".$row['SongTitle']." ~ ".$row['SingerGroup']."'>".$row['SongTitle']." ~ ".$row['SingerGroup']; }else{ echo "<OPTION VALUE='".$row['SongTitle']." ~ ".$row['SingerGroup']." ~ ".$row['AlbumName']."'>".$row['SongTitle']." ~ ".$row['SingerGroup']." ~ ".$row['AlbumName']; } } ?> </select> </td> </tr> Anyone have any clue as to why this is?
  2. I got to thinking maybe I should add a little more detail: So if I have an input box, and as I type into the box "Love" the drop down list would automatically go to the first song with "Love" in it.
  3. Usually, I can Google what I need for JavaScript and simply alter the code to do what I want. However, I could not find anything like this, probably because I'm Googling the wrong key words. I have a database filled with the names of Songs. I can spit the list of songs out into a drop down list. However, now that I have 5,000 songs in there, this is becoming more of a pain in searching for the songs. Even a multi-line list box isn't so great anymore. What I'd like to create is a INPUT search box, and as you type into the search box, it will automatically select the right song in the list box. The rest of the site is in php, but I assume I need JS to do this. Can someone point me in the right direction here?
  4. This what you're looking for? <form action="partnerRequest.php" method="post"> <input type="radio" name="becomeassoc" onClick="this.form.submit()"><span class="f_right">Become Associates</span><img src="../assets/img/becomeassoc.jpg" class="mrs vmiddle" alt="Become Associates" /> </form> Doesn't have to be a radio button, could be a checkbox or whatever.
  5. I've been coming here off and on for about a year. I'm always amazed at the level of help I have been getting... and for free. Well... I figured it's time to give back, so I signed up for a subscription. I have never read one book on coding in php. I simply google php code examples and try them out, and make them work for me. This of course, usually causes a problem down the road because I don't fully understand what it's doing. Then I come here and someone explains it to me, and helps me fix it. I just wanted to say "Thank You" for providing such a useful, and helpful forum. -Ken Evans
  6. Erm...uh... nvm... solved my own problem. This works beautifully... not sure if it's the best method or not, but it works. $result = mysql_query("SELECT * FROM MusicFiles ORDER BY SongTitle ASC"); while($row = @mysql_fetch_array($result)){ $FileID = $row['MusicFiles_ID']; echo $row['SongTitle']."<br>"; $result2 = mysql_query("SELECT * FROM Chords_Loops_Lyrics WHERE MusicFiles_ID='$FileID'"); while($row2 = @mysql_fetch_array($result2)){ echo "->".$row2['Type']."<br>"; } }
  7. Is there a way to check two tables and sort of nest the SQL? This is what I want to do in theory: $result = mysql_query("SELECT * FROM MusicFiles ORDER BY SongTitle ASC"); while($row = @mysql_fetch_array($result)){ $FileID = $row['MusicFiles_ID']; echo <all results>; $result2 = mysql_query("SELECT * FROM Chords_Charts_Lyrics WHERE MusicFiles_ID ='$FileID'"); while($row2 = @mysql_fetch_array($result2)){ echo <all sub related results>; } } The tables are: Table: MusicFiles MusicFiles_ID Type SongTitle SingerGroup AlbumName Table: Chords_Loops_Lyrics CLL_ID MusicFiles_ID Type FileName The idea is that one song may have many other files attached to is... so I want the output to basically be like this: 1 | Song | Dead Or Alive | Bon Jovi | Best Of Bon Jovi 2 | Song | Outlaws | Bon Jovi | Best Of Bon Jovi -> Lyrics -> Chords 3 | Song | Stairway to... | Eagles | Classics
  8. LOL. I knew it had to be some simple syntax, I was missing the "[]". I should've realized this from coding one dimensional arrays, but... oh well. In any case, the first example you gave me works perfectly! The second example you gave me simply does what my original code did, it's keeps overwriting and only shows the last entry on the print_r results. Thank you Ken. You've been a great help to me about 4-5 times on here.
  9. $result = mysql_query("SELECT * FROM Chords_Loops_Lyrics ORDER BY MusicFiles_ID ASC"); while($row = @mysql_fetch_array($result)){ $Chords_Loops_Lyrics = array($row['CCL_ID'] => $row['MusicFiles_ID'], $row['Type'], $row['FileName']); } I know I'm doing this wrong, because of the results. How can I assign values to this array, when I do a print r on this, it only spits out the last value. I need to store like 100 of these "chord loops and lyrics" into an array with the values you see in the $row fields. I just can't seem to find how to properly write this in php.
  10. http://php.net/manual/en/control-structures.while.php Start there.
  11. Just curious, but are the $id values set to nothing or NULL? } else if($id == ' ') { In any case, you have a space in there where $id == ' ', so it's checking to see if the $id is equal to the equivalent of a space. Try removing that space. } else if($id == '') {
  12. I know this form doesn't really work, but the FTP part *should* work. I select a file, and click upload, Chrome shows the file is uploading and gets to 100% then fails. I'm getting "File Upload Failed!" on line 112 every time, but I can't seem to figure out why. I'm hoping a pair of expert eyes can spot it quickly. Upload A File: <form enctype="multipart/form-data" action="File_Upload.php" method="POST"> <table> <tr><td>Song Title:</td><td><input></input></td></tr> <tr><td>Singer/Group:</td><td><input></input></td></tr> <tr><td>Album Name:</td><td><input></input></td></tr> <tr><td>Video Link:</td><td><input></input></td></tr> <tr><td>Category:</td><td><input></input></td></tr> <tr><td>Choose a file to upload:</td><td><input name="uploadedfile" type="file" /></td></tr> <tr><td><input type="submit" value="Upload File" /></td></tr> </table> </form> <?php //********************************************************************************************** echo "Please wait while we attempt to upload your file...<br><br>"; //********************************************************************************************** $target_path = "temp_uploads/"; $flag = 0; // Safety net, if this gets to 1 at any point in the process, we don't upload. $filename = $_FILES['uploadedfile']['name']; $filesize = $_FILES['uploadedfile']['size']; $mimetype = $_FILES['uploadedfile']['type']; $filename = htmlentities($filename); $filesize = htmlentities($filesize); $mimetype = htmlentities($mimetype); $target_path = $target_path . basename( $filename ); if($filename != ""){ echo "Beginning upload process for file named: ".$filename."<br>"; echo "Filesize: ".$filesize."<br>"; echo "Type: ".$mimetype."<br><br>"; } //First generate a MD5 hash of what the new file name will be //Force a MP3 extention on the file we are uploading $hashedfilename = md5($filename); $hashedfilename = $hashedfilename.".mp3"; //Check for empty fileif($filename == ""){$error = "No File Exists!"; $flag = $flag + 1; //Now we check that the file doesn't already exist. $existname = "temp_uploads/".$hashedfilename; if(file_exists($existname)){ if($flag == 0){ $error = "Your file already exists on the server! Please choose another file to upload or rename the file on your computer and try uploading it again!"; } $flag = $flag + 1; } //Whitelisted files - Only allow files with MP3 extention onto server... $whitelist = array(".mp3"); foreach ($whitelist as $ending) { if(substr($filename, -(strlen($ending))) != $ending) { $error = "The file type or extention you are trying to upload is not allowed! You can only upload MP3 files to the server!"; $flag++; } } //Now we check the filesize. If it is too big or too small then we reject it //MP3 files should be at least 1MB and no more than 25 MB if($filesize > 26214400){ //File is too large if($flag == 0){ $error = "The file you are trying to upload is too large! Your file can be up to 25 MB in size only. Please upload a smaller MP3 file or encode your file with a lower bitrate."; } $flag = $flag + 1; } if($filesize < 1048600){ //File is too small if($flag == 0){ $error = "The file you are trying to upload is too small!Your file has been marked as suspicious because our system has determined that it is too small to be a valid MP3 file.Valid MP3 files must be bigger than 1 MB and smaller than 25 MB."; } $flag = $flag + 1; } //Check the mimetype of the file if($mimetype != "audio/x-mp3" and $mimetype != "audio/mpeg"){ if($flag == 0){ $error = "The file you are trying to upload does not contain expected data.Are you sure that the file is an MP3?"; }$flag = $flag + 1; } //Check that the file really is an MP3 file by reading the first few characters of the file $f = @fopen($_FILES['uploadedfile']['tmp_name'],'r'); $s = @fread($f,3); @fclose($f); if($s != "ID3"){if($flag == 0){ $error = "The file you are attempting to upload does not appear to be a valid MP3 file.";}$flag++; } //All checks are done, actually move the file... if($flag == 0){ if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { //Change the filename to MD5 hash and FORCE a MP3 extention. if(@file_exists("../music/".$filename)){ //Rename the file to an MD5 version rename("uploads/".$filename, "uploads/".$hashedfilename); echo "The file ".basename( $filename )." has been uploaded. Your file is <a href='uploads/$hashedfilename'>here</a>."; } else{ echo "There was an error uploading the file, please try again! (1)"; } } else{ echo "There was an error uploading the file, please try again! (2)"; } } else { echo "File Upload Failed!<br>"; if($error != ""){ echo $error; } } ?>
  13. TapeGun007

    iTunes

    I found some neat stuff where you can pull up the iTunes XML file with PHP and parse it to whatever format you would like. But the question I have is... iTunes has a little search box. Is there a way to call up iTunes with php, and have it spit out search results by clicking a button? For example, if I see a button that says "stairway to heaven" click here, and you click it and it brings up an iTunes search box with that song and whatever is related to it.
  14. SELECT Departments.Dept_ID, Departments.Dept_Name, Department_Members.Dept_ID, Department_Members.MemberID, Department_Members.DM_ID, Members.FirstName, Members.LastName FROM Departments, Department_Members, Members WHERE Departments.Dept_ID = Department_Members.Dept_ID AND Members.MemberID = Department_Members.MemberID I did this and it works, but... is this really the correct way? I made a small mistake on the original example, MemberID isn't "Member_ID".
  15. Here are the tables: Table: Members Member_ID FirstName LastName Table: Departments Dept_ID Dept_Name Table: Department_Members DM_ID Dept_ID Member_ID I want to be able to spit out the Dept_ID, Dept_Name, Member_ID, FirstName, LastName. I just did a JOIN, but now this is kind of a 3 way join, is that possible?
  16. Thank you very much. The more I had went back and thought about it and then reread your post, the more I know that you are right. Again, I'm a bit new to this... well... the more complex db's now. Always learning something new.
  17. I do not proclaim to be a db expert, so I'm just looking for some good advice here. I will have multiple departments that I want to be managed on the website. Each department will only simply contain who is in charge, and all the members of that department. In the past, I've stored all this in one table like "Departments" or whatever. Since each department is basically a cookie cutter of every other department, I've thought about creating a table for each department instead. So each table name would be like "department_Hardware", "department_Software". This way if we shut down a department, all I have to do is delete that table. Which is better?
  18. I wish it were that easy. The people writing the emails are not HTML knowledgeable. They don't know what <b> does. So I have a WYSIWYG editor that works well on every other part of the site. Like I have a calendar, and if they put an event on there in bold, it simply shows up as bold on the calendar. They aren't having to code it. In this case, they need to be able to create bold items, bulleted items and such. I wanted to make the email form very user (and HTML ignorant) friendly.
  19. Actually... what you suggested didn't work, but I now know WHY. I'm using a Javascript text editor, I use it in several places on my website. For some reason, the form that submits the text for the created email is stripping all the HTML tags. For example, I use the text editor to update the front page news. So if someone highlights a word and makes it bold on the screen, it writes that information to the db as HTML code. But for some reason on this email form, it is removing all the HTML code. Not sure why, it's the exact same text editor... I'll have to review my other code to see what I did there I guess.
  20. Using Outlook 2007 and I get HTML emails all the time. No, the email being sent does NOT include the <body> tags and all that... I assumed it was sent... maybe that's the issue. For whatever reason, I just assumed that was already there and oddly enough, didn't think of it. duh >.<
  21. $headers = "From: [email protected]\r\n" . "Reply-To: [email protected]\r\n" . "BCC: ".$bcc."\r\n" . "Content-type: text/html\r\n"; The email sends fine, it's a form that you input some information into and it collects all the emails of the people that need to be notified. The only issue is that it's not in HTML. So, if in the email you send a <b> or <p>, it actually shows up in the email instead of actually make the text BOLD or whatever. Am I using the Content-type wrong?
  22. This may not be the answer that you want to hear, but you can simply create buttons "back" and "forward" such that would repost the information you need.
  23. I was going to try this and tell me what you get: $result = mysql_query("SELECT * FROM teams'"); while($row = @mysql_fetch_array($result)) { echo $row['id']. $row['name']."<br>"; }
  24. Pikachu2000 was correct. I set the redirect in the header to have the full domain name and the issue went away. I thought I had caught everything prior, but missed one header. I now have rid myself of double log ins. The interesting thing is, however, once that session is started, and the page redirects the person, I never need to worry about whether that link has the full domain name in it again. Every other page works just fine. Not sure why php is so inconsistent like that, but, at least it's fixed. Hope this helps someone in the future. So... the fix was, after a user logged in (email and password verified), I changed the header. This is the code that did NOT work: header('Location:index.php'); Changed to: header('Location:http://www.mydomain.com/index.php');
  25. More than likely because I don't know how. I fairly new to php and MySQL. Back to the main point here, I see lots of issues people getting double logins and such on Google. Unfortunately, nothing they have suggested is working so far.
×
×
  • 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.