Jump to content

SharkBait

Members
  • Posts

    845
  • Joined

  • Last visited

    Never

Everything posted by SharkBait

  1. IE 6. Unless I have some weird tag issues happening. (perhaps not a closed tag somewhere?) I am thinking it could be a tag issue because Firefox seems to understand what you're trying to do if things aren't perfect, where as IE freaks out and dies. lol Both forms in the page have opening and closing <form></form> tags.
  2. Am I allowed to have multiple forms on a single web page? <form action="search.php" name="meh" method="post"> <input type="text" name="name" /> <input type="submit" name="newname" value="Lookup"/> </form> <p>Some stuff here</p> <form action="<?php $_SERVER['PHP_SELF'];?>" method="post" name="blah"> <input type="text" name="address" /> <input type="submit" name="newaddress" value="Go" /> </form> With Firefox it works fine. I click on the 'Go' button and the page POSTs into itself. But with IE it will POST into the search.php page which is what I don't want. Am i doing something wrong? Or is IE truely retarded? I find Firefox to be more forgiving when there are little issues with HTML etc.
  3. Ah ok. I thought I could do a query within a query but wasn't quite sure how to go about doing it. I also made sure I renamed the field because seats - (SELECT COUNT(*) etc is a bit much to put into a variable. lol SELECT *, seats - (SELECT * FROM table2 WHERE table1_id = id) as seats FROM table 1 Works nicely thanks!
  4. I have two tables that reference each other but what I am trying to do is select a row in one table and then subtract a COUNT() from another query to give me the result. Let's see if i can explain this better. Table1 id | seats | venue --+------+-------- 1 | 30 | GM Place --+------+-------- 2 | 34 | BC Place --+------+-------- Table2 id | table1_id | customer --+-----------+------------- 1 | 1 | Jim Bob --+-----------+------------- 2 | 1 | Billy Bob --+-----------+------------- 3 | 2 | Sammy D --+-----------+-------------- So I want to be able to return from Table1 the remaining `seats` by counting up the rows and minusing the ones from table2 based on Table1.id = Table2.table1_id So the result row would return 28 seats left for `GM Place` and 33 seats for `BC Place`
  5. I figured out how i can do it using in_array()
  6. How would I go about comparing two arrays to see a) if they match b) if one array has values the other doesnt etc? Example: $arr1 = array("tyler", "bob", "jen"); $arr2 = array("tyler", "jen", "alice", "tom"); If the arrays match, then I want to exit and do nothing. If $arr1 has items in it that $arr2 doesn't then I am looking to print out the differences only. So the older stored array is $arr1 (think of it being stored in a database). When I get $arr2 I want to see how much different array 1 is from array 2. if there is a differnce then show what has changed and then update the row in the table. So tyler, bob and jen are in the table. But now alice and tom have joined but bob has left. Is this easily done?
  7. Ah that's it. Thanks! Helps keeping things uniformed and easier to update!
  8. Ok I am having some weird thinking issues and trying to make a website more... universal throughout so hopefully I can explain it well enough to hopefully get some help with it. /index.php /mysql_connect.php /funcs.php /includes/header.html /includes/footer.html /products/index.php Ok take that as an example. I want to be able to create a 'global' variable that i can set in /includes/header.html that will allow me to have /products/index.php require /includes/header.html and /includes/footer.html properly. /includes/header.html also includes /mysql_connect.php and /funcs.php Or are /mysql_connect.php and /funcs.php in the wrong place for this to work properly? when i add require('/includes/header.html"); and require("/includes/footer.html"); in the /products/index.php file. I get errors that it can not find the /mysql_connect.php file nor the /funcs.php file. Does this make sense??
  9. Ah get_file_contents worked nicely! Thanks
  10. I know how to read files and such but I am trying to retrieve a file that prompts you to download. It actually is a CSV file but I am wondering if PHP will be able to read the contents of it if I pass the URL to it. I want to be able to read this file: http://download.finance.yahoo.com/d/quotes.csv?s=TZT.TO&f=sl1d1t1c1ohgv&e=.csv when then prompts you to download it to your desktop. I would want to be able to have PHP take that file, parse it and then use the data I pull from it. Could I use fopen() or would I have to look into something else like cURL?
  11. Oh so instead of echoing.. just concat the output and return that...
  12. Ok if i use a While() loop would replace it as it finds it? <?php $code = "/\[poll=(\d+)\]/ise"; $replace = "display_poll('\\1')"; while(preg_match($code, $replace) { $str = preg_replace($code, $replace, $str); } ?> I use something similar when I want to replace with <div class="quote"></div>
  13. <?php function display_poll($poll_id = 0, $POLL_WIDTH = 300) { if($poll_id == 0) { // No ID set to show latest poll $strqry = "SELECT id FROM blog_polls ORDER BY id DESC LIMIT 1;"; $query = mysql_query($strqry) or die("MySQL Error: <br />{$strqry}<br />". mysql_error()); $result = mysql_fetch_array($query, MYSQL_ASSOC); $poll_id = $result['id']; } $strqry = "SELECT * FROM blog_polls WHERE id = '{$poll_id}'"; $query = mysql_query($strqry) or die("MySQL Error: <br />{$strqry}<br />". mysql_error()); $poll_question = mysql_fetch_array($query, MYSQL_ASSOC); $question = $poll_question['question']; // Display Question (header of poll echo "<div class=\"MyPoll\" style=\"width: {$POLL_WIDTH}px; border; 1px solid #000; padding: 5px;\">\n"; // Get Question for Poll echo "<div style=\"text-align: center;\"><strong>{$question}</strong><br /></div>\n"; // Find out if user has answered poll // Query to see if User's IP address has already voted $strqry = "SELECT ip_address FROM blog_polls_answers WHERE ip_address = '{$_SERVER['REMOTE_ADDR']}' AND poll_id = '{$poll_id}'"; $query = mysql_query($strqry) or die("MySQL Error: <br />{$strqry} <br />". mysql_error()); if(mysql_num_rows($query) == 0 || $ADMIN) { // User has not voted (based on IP Address) // User has not voted yet based on their IP Addrss - Show them Voting Form // Get Options for Poll $strqry = "SELECT * FROM blog_polls_options WHERE poll_id = '{$poll_id}'"; $query = mysql_query($strqry) or die("MySQL Error: <br />{$strqry}<br />". mysql_error()); $i = 0; // Loop through options and create 2D array using Question as main index while($poll_questions = mysql_fetch_array($query, MYSQL_ASSOC)) { $poll_info[$poll_question['question']][$poll_questions['id']] = $poll_questions['choice']; $i++; } //print_r($poll_info); echo "<form action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">\n"; // Loop through the values in the Poll Info Array which are the Choices for the Poll Question foreach (array_values($poll_info) as $options) { // Need to loop through the options because they are stored in a 2D array foreach($options as $id => $option) { // Print out the choices in the form of radio buttons echo "<input type=\"radio\" name=\"poll_answer\" value=\"{$id}\"> {$option}<br />\n"; } } echo "<br />\n"; echo "<input type=\"hidden\" name=\"PollID\" value=\"{$poll_id}\" />\n"; echo "<input type=\"hidden\" name=\"IPAddress\" value=\"{$_SERVER['REMOTE_ADDR']}\" />\n"; echo "<div align=\"center\"><input type=\"submit\" name=\"PollVote\" value=\"Vote\" /></div>\n"; echo "</form>"; } else { // User has voted - Show Results //Query to find out total votes for figuring out percentages $strqry = "SELECT COUNT(*) FROM blog_polls_answers WHERE poll_id = '{$poll_id}' GROUP BY poll_id"; $query = mysql_query($strqry) or die("BLAH"); $num_votes = mysql_fetch_array($query, MYSQL_ASSOC); // Query to find voting levels $strqry = "SELECT T1.poll_Id, T1.option_id, T2.choice, COUNT(*) FROM blog_polls_answers AS T1 LEFT JOIN blog_polls_options AS T2 ON(T1.option_id = T2.id) WHERE T1.poll_id = T2.poll_id AND T1.poll_id = '{$poll_id}' GROUP BY option_id"; $query = mysql_query($strqry) or die("MySQL Error: <br /> {$strqry} <br />". mysql_error()); // Loop through count and display bar, percentage and choice while($votes = mysql_fetch_array($query, MYSQL_ASSOC)) { $count = $votes['COUNT(*)']; // Round to 2 decimals $percent = round(($count / $num_votes['COUNT(*)']) * 100, 2); $barWidth = 170 * ($percent / 100); // Show Result echo "<div style=\"width: 98%; font-size: 9pt; padding-top: 10px;\">"; echo "<div style=\" background-image: url('/images/poll-bar.gif'); background-repeat: repeat-x; float: left; width: {$barWidth}px; margin-right: 5px;\"> </div> <strong>{$percent}%</strong><br />"; echo "{$votes['choice']}<br />"; echo "</div>\n"; } echo "<hr />Total Votes: {$num_votes['COUNT(*)']} <br />\n"; } echo "</div><br />\n"; } ?>
  14. Quick fix: you could do something like this which uses Javascript: http://www.htmlcodetutorial.com/forms/index_famsupp_157.html
  15. I had this issue also. Hitting the 'enter' key is different than hitting the submit button it self. I'm looking for my script that checks... when i'll find it I'll post it.
  16. I am trying to replace something within a block of text with something else and it works. But I would like to have it replace the text and leave it in the place it found it. <?php $str = "This is some text that I would like to display. There is a poll at the end of is [poll=3]"; $str = preg_replace("/\[poll=(\d+)\]/sie", "display_poll('\\1')", $str); ?> When the code runs, it will replace [poll=3] with the proper code but it puts it at the beginning of the string and not where the [poll=3] is seen. Am I doing something wrong? You can see an example here: http://www.tyleringram.com/blog/The-Real-Meaning-Of-Christmas the poll should actually be _after_ where it says 'I have also placed a poll here'
  17. I am looking over my processlist and looking at the Sleep times. Am I right to assume the Sleep times are down in Milliseconds? By default how long does MySQL wait till it kills the processes if it's been sitting idle? As of right now there are 30 processes and 29 of them are Sleeping. I'm looking to see if there is anything I can do to perhaps allivate some of the connections if they aren't being used within a certain time. Any advice/suggestions greatly appreciated
  18. What should the proper file permissions be for Apache into web directories? Example: users: jim, bob, steve groups: www-data, webadmin Now if i set www-date (apache's group) to that of webadmin and then add jim, bob to the webadmin group that would make sense right? /home/steve/public_html would look like: drwxrwxr-- steve:webadmin (774) Would that allow apache, jim and bob work in the directory without issues? With those above permissions would Jim/bob (part of the WebAdmin group) still be able to create files within steve's public_html folder?
  19. I had to make sure i had the php5-json package installed in my ubuntu release (dapper) to make sure the PECL extensions where there but its all good now! Thanks again!
  20. Oh thanks for the info. Well I guess it is a bit more AjAX question than application design. Is a mod would like to, please move it at your leisure
  21. I'm working on a small project and wondering what is the best way to about extracting multiple variables using ajax and php. I have a form with various fields and with one field when you enter a value it can do a database look up and hopefully automatically fill out the related fields in the same form. Now I could put all the values I retrieve (via MySQL) into a single string and delimit it with a ; or something via PHP and then have javascript process the string and split the variables up to go back into the various form fields I have. Seems ok right? Or would I look at using XML and having PHP create some sort of XML response that I can then use javascript to parse though and insert the values into the appropriate locations? What the users enter is a single value and queries the database for the exact match which will return up to 5 other values which then the user would not have to enter manually. (its a search type feature). Hope this makes sense, if not I can screenshot the form and draw in what goes where
  22. You mean things like Facebook, Nexopia, Hi5, MySpace etc? Or more on a business level?
  23. Ah what I was looking for was to keep the query string intac as i passed it to another page. RewriteCond ^{QUERY_STRING} ^m=show&id=([0-9]+)$ RewriteRule ^ index2.php All works now It is because of the question mark that I want to keep it will see it as a URL query.
  24. Hi, I want to be able to have a URL like this: www.myurl.com/?m=show&id=3 which normally points to index.php redirect to index2.php. This is what I have but I think the first ? is messing up the rule: RewriteRule ^?m=show&id=([0-9]+)$ index2.php?m=show&id=$1 What can I do do correct it? I tried escaping the ? by using \? but that didn't work.
  25. Ok... Has anyone use SEO companies for projects for getting a better ranking on search engines for particular keywords? I am asking because my employer wants a better ranking for particular keywords and I have not looked into SEO to too much for the industry they are in. I understand content is king when it comes to search bots crawling to index. Or does anyone out there have any good reference sites I can look through. Most SEO I've done really is for making URLs human/bot friendly etc. Thanks
×
×
  • 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.