Jump to content

mpharo

Members
  • Posts

    221
  • Joined

  • Last visited

    Never

Everything posted by mpharo

  1. this what your lookin for? chr (PHP 4, PHP 5) chr — Return a specific character Description string chr ( int $ascii ) Returns a one-character string containing the character specified by ascii. Example 2306. chr() example <?php $str = "The string ends in escape: "; $str .= chr(27); /* add an escape character at the end of $str */ /* Often this is more useful */ $str = sprintf("The string ends in escape: %c", 27); ?> You can find an ASCII-table over here: » http://www.asciitable.com. This function complements ord(). See also sprintf() with a format string of %c.
  2. You have 2 Where statements in there, that wont work at all...try this... $sql = "SELECT * FROM `s2007schedules` WHERE division='$division' ORDER BY datefield ASC"; you must replace datefield with the field that contains your dates in your table
  3. SELECT * FROM table WHERE field='$var' ORDER BY datefield ASC
  4. In your SQL table I assume you have a date field, just add an ORDER BY to your SELECT statement on the date field then add an ASC to go from first date to last or DESC to go last date to first...
  5. The MAX function returns the maximum value of an expression. If it is an auto increment field which is not associated with an id for a thread, the max will just give the highest value on that row, which will be the last entry....I think he has it setup like this.... New Thread actionID=1 subjectID=1, etc.. new Reply actionID=2 subjectID=1, etc.. New Thread actionID=3 subjectID=2, etc... So if you do a max(actionID) it will give the highest value (the last row) in the table, where if you do a WHERE subjectID=1 it will give a highest value for that post...i would restructure your table a little if this is how it is setup, but I could be completly wrong...
  6. Are you inserting them in the table as an array or into each of their seperate fields?
  7. I think you need to add a WHERE clause in your SQL statement on the subjectID, the query you have looks correct except it is looking for all results and returning the last one, what you want if I am understanding is the last one for this thread or subjectID.... I could be wrong, but this is what it looks like without seeing your table structure and how the threads are being inserted...
  8. If I am getting it right this is what you would do like the previous post has but you would compare the sql result to the value in your option...something like this... <select> <option value="TEST" <? If ($sql[result]=='TEST') { echo "selected"; }?>>TEST</option> </select> It is much cleaner if your not breaking in and out of php to html and just use an echo statement to generate the html...
  9. hello, I am working on a site to display thousands of results....I have all of that working but I want to limit the results to 50 at a time...any suggestions on how to browse the results with a limit of 50....I am thinking about checking the value of a number and while it is less than the total count of rows in the query increment it by 50....if anyone has a snippet it would be appreciated.
  10. the foreach worked great...thanks for your help...
  11. I have the following code... $category is an array generated from a previous query which has different amounts.... for ($i=0;$i<=count($category);$i++) { $select2=mysql_query("SELECT * FROM traffic WHERE category LIKE '%$category[$i]%'") or die(mysql_error()); $total=0; while($sql2=mysql_fetch_array($select2)){ $total++; } } does anyone know of another way I can take each element in an array and use it for a query other than this??
  12. What I want is just a count of $total for each distinct category in the second query right now I get that along with a total count for all categories..
  13. I am having a looping issue, when i execute this code I get a total count of all items at the end of each echo...I think it is simple but any help is appreciated... <? $select=mysql_query("SELECT DISTINCT category FROM traffic") or die(mysql_error()); while($sql=mysql_fetch_array($select)) { $category=explode(",", $sql['category']); for ($i=0;$i<=count($category);$i++) { $select2=mysql_query("SELECT * FROM traffic WHERE category LIKE '%$category[$i]%'") or die(mysql_error()); $total=0; while($sql2=mysql_fetch_array($select2)){ $total++; } echo "Total: " . $total . "\n"; echo "Cat: " . $category[$i] . "\n"; } } ?>
  14. Is the serialize option faster than implode? the reason why I had the $result=Array(); was cause I kept getting an error and it wouldnt allow me to do an array_push() I assumed that the variable needed to be initialized as an array before you could push to it...
  15. I dont think that is really what im looking for....essentially here is the deal... I have an array which contains random amounts... I need to take that array and put it into a single variable with a comma seperating eash element in the array... Here is a example of what I have now where I create the array $result, I need to take $result and put it into a different variable seperated by commas.... <? $select2=mysql_query("SELECT category FROM blacklist WHERE domain='$matches[0]'"); $count_rows=mysql_num_rows($select2); If($count_rows>1){ $result=Array(); while($sql2=mysql_fetch_array($select2)){ array_push($result, $sql2[0]); } } print_r($result); ?>
  16. I have an array which is generated by the result of an SQL query... What I am trying to do is take that array and insert it into a different table in a single field, so what I am trying to do is make all the elements in a array into a single variable I can use to insert into a field with each array element seperated by a comma. This would be easy if the array had the same amount of lines each time but it dosent, sometimes the array has 1 element sometimes it has 5....any ideas??
  17. So if your wondering ( prolly not ) but here is a little code to represent what he is saying in the above post.... $query="SELECT * FROM table"; $i=0; while($sql=mysql_fetch_array($query)) { echo "Result: " . $sql[$i++] . "\n"; } Something like that...might be a little off...if you dont want to do it by array index's then just replace the $i++ with the column name you want to view....
  18. After re-reading the post it seems like boo is correct, you should be getting only 1 result if all the actors are in the same field in the same table....
  19. I am having a similar issue, What I thought about doing is checking if the query returns more than one result using the mysql_num_rows() function and then using the array indexes to import them to a single variable...something like this.... $var="$sql[0],$sql[1]"; I am not sure if this will work in your case because it seems your array indexes are not working, have you tried just printing the array results with the print_r() function?
  20. I am writing a reporting tool for the open source project Dansguardian, right now I am taking a URL that a user has visited and need to compare it to a blacklist, which contains just domain names (i.e. - phpfreaks.com). I currently have some code which does this but it does not work for https URL's. Here is the code: while($sql=mysql_fetch_array($select)) { preg_match('@^(?:http://)?([^/]+)@i', $sql, $matches); $host = $matches[1]; echo "host is: $host\n"; preg_match('/[^.]+\.[^.]+$/', $host, $matches); echo "domain name is: {$matches[0]}\n"; } I then found the parse_url(); function and tried using that, but that dosent strip off the subdomains. It just returns the host. Does anyone have a snippet or a modification they could suggest? Thanks in advance...
×
×
  • 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.