Jump to content

jyushinx

Members
  • Posts

    36
  • Joined

  • Last visited

    Never

Everything posted by jyushinx

  1. Quick change. I posted the code before I refined it a bit more: SELECT i.id, i.ItemName, i.ItemPrice, i.ItemDescription, a.awardid FROM ItemsTable i LEFT JOIN awards_table a ON i.id = a.itemid WHERE CategoryType=2 GROUP BY i.id
  2. Sorry for the extreme delay. I've been away. I wanted to post that Barand's solution plus an additional tweak solved the issue. Because certain items can win multiple awards, and I wanted only distinct items returned, I added a GROUP BY. So: SELECT lj.* FROM (SELECT i.id, i.ItemName, i.ItemPrice, i.ItemDescription, a.awardid FROM ItemsTable i LEFT JOIN awards_table a ON i.id = a.itemid WHERE CategoryType=2) AS lj GROUP BY lj.id
  3. I figured it would be with a LEFT JOIN, but when I was trying it out, I couldn't get it to work correctly. Let's do an example... Say we are doing a search for elements in the Items table that are of CategoryType 2. Now of these returned elements, we need to know which ones have won awards. So the basic SQL (without the LEFT JOIN) would be: SELECT ItemName,ItemPrice,ItemDescription FROM ItemsTable WHERE CategoryType=2 What would the SQL be so we ended up with another column that designates whether or not the item won an award? Thanks.
  4. So this is my issue: I have a table that houses a large number of Items. There is another table that houses award information for certain items. This table is essentially comprised of ItemId and AwardId. I need a single query statement that will mark which items have awards when a generic list of items is requested. The purpose would be to include a special graphic next to the items that have awards. This is basically a statement that will let me know if each element exists in another table. Thanks.
  5. Hi, I currently have code which searches a string for unclosed html tags. It works well except for one glitch. A tag like <br/> will be read as closed. But a tag such as <br /> won't. Clearly there is something up with my regex, but I have no idea as I am clueless with it. Here is the code for finding open tags preg_match_all("#<([a-z]+)( .*)?(?!/)>#iU",$html,$result); Any ideas as to how I can modify the regex to recognize tags as being closed like <br /> Thanks.
  6. Hi, I have a situation where I am pulling text previews from a database using the SUBSTR mysql function. The issue with this is that it can cut right through tags, leaving them unclosed. This obviously causes problems with the site display. I need a function which will run through the chunk of HTML and add any necessary closing tags. I've found one or two of these functions floating around the internet, but I keep running into the same issue with them: they do not interpret tags such as <input /> as being closed. So they add a </input> tag even though it is unnecessary. This could cause some serious display problems with the page. For example, if there was a tag <div />, then the parser would add a </div>. Not good. Why would a tag <div /> be used you ask? Well this is user input. Who knows what's going to be done. I expect the worst though. Does anyone have or know of any functions which is more intelligent when finding open ended tags and closing them? Thanks.
  7. Excellent. That makes perfect sense. I've done something like that before, but was so wrapped up in figuring it out "this way" I didn't step back and realize that. Thanks.
  8. Hi, I have searched and searched for an answer to this question, and while there are many posts on it floating around, I have yet to find both a) a solution to my exact problem and b) one that actually works. Let me explain the situation so you can see what I am trying to do. I have a page, let's call it message.php, which contains a form where a person can write a message to be sent. When they click Submit, the form redirects to another script, let's call it message_processor.php, which deals with the information from message.php. Now, message_processor.php checks for valid data, and if it finds one of the fields is invalid (empty, too long, etc.) I want it to redirect back to message.php, where the form can be displayed with an error message. Now in the past, I have always used GET variables to deal with this, so in message_processor.php if there were an error, we'd use something like this: header("Location: http://www.mysite.com/message.php?errorId=34"); Which works fine, except if I want to send a large amount of data. Too large for a query string. So say I want to return to message.php with not only the errorId, but also the form data, so the user doesn't have to re-enter it. And say that one of these form elements is very large, say 2500 characters. Is there a way to do this using a POST or something similar? From my readings, I understand the contradiction in this request. POSTS are sent from Browsers to the server. So I can redirect to an address using header(), or I can send POST info using cURL, etc. to a script, but what I need is to essentially do both at once. Send POST info to a script and have that script become the location in the browser. So first question, what is the actual max length of a Query String, assuming you are using a browser that isn't from the Stone Age? I've read differing reports, so I'm a bit lost on this. Second question, is there any way to achieve what I described either with POST variables or something similar using PHP? Thanks for the help. I tried to be as descriptive as I could, but let me know if something is unclear in my request.
  9. Hi, What I am trying to do is have a setup where a person clicks on Accept (for Terms & Conditions) and is then directed to a page thanking them for their download and in 10 seconds or so, the download prompt will appear asking them to save or open the file. It's a common thing on a lot of websites (downloading drivers for one). One other thing is that I don't want the path to the file to be seen by the user. The way I have it setup now, the user clicks on Accept, which is linked to a PHP script forcing the download. The downloadable file is put in a directory a few levels down so the user can't attempt to use the script to download a PHP file. The problem is, I don't know how to load a page and use this method (which uses headers). Thanks for your help.
  10. That makes sense. Thanks for the explanation.
  11. Well my initial motivation was because I was going to delete the cookie to make sure that when I refreshed the page, a new Session was generated. That wasn't a pressing issue or anything, but now I want to know for information's sake. I like to understand how it functions because I don't like assuming things will just "work" without understanding the underlying mechanism. I've found that this sort of assumption leads to more trouble if you ever run into a problem down the road.
  12. I understand they are different, but it seems that if the cookie is not present, the session is no longer valid. You can see this by the way it behaves in Firefox. The cookie is set with an SID. If I delete the cookie and try to refresh the page a new session is started along with a new SID. With IE, I just closed the program and reopened it. I navigated to the page in question and was prompted to set my session cookie with an expiry marked as "End of session". I clicked allow and voila, I cannot find this cookie anywhere. Where is it going? It has to be somewhere.
  13. revraz, I already looked in that location (that's what I meant by saying I checked with Windows Explorer) . I looked in both C:\Documents and Settings\user\Local Settings\Temporary Internet Files & C:\Documents and Settings\user\Cookies. The cookie is nowhere to be found. p2grace, I know that you can control the session lifetime in php.ini, but when it is not explicitly set (which it isn't), what is the default? Thanks.
  14. Hi, I am having a bit of an issue working with a PHP session in IE7. I'm just starting to set this up, so for informational purposes, all I have is a page that starts a session and then displays the SID. Now in Firefox, I start a session and it places a session cookie on my system. If I kept refreshing this page, the cookie still exists and thus the session, so it keeps displaying the same SID. Now if I deleted the cookie, a new session would be created on my next refresh with a new SID and cookie. In IE7, I cannot find the cookie for the session. I checked using Nirsoft Cookie Viewer as well as looking myself in Windows Explorer. There is no cookie. However, when I refresh the page, the SID stays the same, as if the session is active and the cookie does exist. Perhaps it does and I just don't know where. Any ideas? Also, in regards to sessions, I was under the impression they had a default lifetime of 3 hours. However, I have left my computer for far longer than this, and when I return, it is still active. Does it only end when the browser is closed? Thanks.
  15. Wow. That worked. The funny thing is this is on a Linux server. Whatever works though. Thanks for your help.
  16. Ok, this thing is killing me. I cannot figure out for the life of me why my script won't work. A point of interest: I was trying to base64_encode the string and then submit to my generatetext script where I would decode and send the file. This was causing the newlines to disappear. However, for the sake of experimentation, I tried not encoding on the submitting page but simply encoded and immediately decoded on the receiving script, it worked fine. So the base64_encode is not the issue. Somehow or another, during the POST process this is getting messed up if it is encoded. Remember, it works fine if it isn't. To give you a better idea of what I am encoding, let me explain a bit. The user is viewing a Paid list. At the same time I generate the HTML for the paid users, I generate the content for the text file. For example: foreach($userList as $user) { //Create HTML Blah Blah Blah //Create text file contents $textFileContents .= $user["Name"].", ".$user["AmountPaid"]."\n"; } I then base64_encode $textFileContents and place it in a hidden value on the form which is posted to my generatetext script, decoded, and sent back as a .txt file. Any more ideas?
  17. The code on the form page is: <form name="generateTextForm" action="generatetext.php" method="post"> <input type="hidden" name="textFileName" value="someFileName.txt"><input type="hidden" name="textFileContent" value="<?PHP print base64_encode($textFileContent); ?>"> </form> The code on the receiving script: $textFileContent = ( isset($_POST['textFileContent']) ? $_POST['textFileContent'] : ""); $filename = ( isset($_POST['textFileName']) ? $_POST['textFileName'] : ""); $textFileContent = base64_decode($textFileContent); if( empty($textFileContent) || empty($filename) ) { exit(0); } else { header('Content-type: text/plain'); header('Content-Disposition: attachment; filename="'.$filename.'"'); print $textFileContent; } When the submit button is clicked on the form page, I am prompted to download a text file, but the the text file reads: Text File Title[][]John Smith[][]Jane Smith The [] is my representation of what looks like a tiny rectangle character. Now when I run this same script without the base64 encoding, the text file has line breaks where those rectangle characters are. Any ideas?
  18. thebadbad, That is exactly what I am looking for. I have one more question however. When I display the list as a hidden input variable, I base64_encode it. The problem is that when I decode it on the other end, I lose the "\n" new line characters. They're replaced with the unknown character symbol. Any ideas how to preserve this? Thanks.
  19. Hi, What I want to do is allow a logged in user to download a text file version of the list they are viewing on the screen. So if they are viewing the Paid list of users, there should be a button on that same page that says Download To Text File, and when clicked, the user is prompted to download a text file version of the list. What is the best practice to go about doing this? Thanks.
  20. Excellent. Worked like a charm. Thank you.
  21. Hi, I am having an issue developing a query to fit a specific need I have. I know what I want to do conceptually, but I don't know how to translate it into SQL. Let me explain: I have a Users table. The Primary Key in this table is UserId. I also have an EventSignUp table. Basically, users can sign up for particular Events, so the Events table consists of a match up of UserId and EventId. What I am trying to do is retrieve all the users who have NOT signed up for a particular event. So given an EventId of 10, I would want to retrieve all the UserIds from the User table where there is not a match up of the UserId and 10 (the EventId) in the EventSignUp table. I hope this is clear enough. If anyone needs further explanation, just say so. Thanks for your help.
  22. The problem with that is the the names of the dishes can vary in length, so using columns isn't ideal. For instance. Hamburger With Everthing ..................... $4.95 Hot Dog .................... $2.00 So with columns, it can only be as small as the largest dish title. As you can see, it creates big gaps with smaller ones. I need to use a span or a div. And even if I use the dots.gif, I need to be able to set the size. Thanks for the responses.
  23. Hi, I'm working on a website for a restaurant. On the menu section, the format is as such: In the first column is the dish name followed by a description (in a span) and then the price in the next column. What I want to do is put a div or a span (whatever would work) after the description and have it automatically stretch from the end of the description to the price column. I would then put a border on the bottom as dots so it has this effect: Hamburger Delicious .............. $4.95 The HTML would look something like this: <td>Hamburger<span>Delicious</span><div style="border-bottom:1px black;width:100%"></div><td>$4.95</td> The problem is that a div automatically displays on the next line. If I set the display to inline, then I can't set the width. Any ideas for a solution? Thanks.
  24. Thanks for your help. That worked perfectly.
×
×
  • 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.