Jump to content

Zane

Administrators
  • Posts

    4,362
  • Joined

  • Last visited

  • Days Won

    11

Everything posted by Zane

  1. w3schools is not the place to learn programming languages effectively. Try tutorials or books elsewhere. http://www.w3fools.com/
  2. $x++ is the same thing as $x = $x + $x
  3. Zane

    Alo!

    Bienvenidas, Esperamos que te disfrutes nuestra comunidad más contribuir ayudas, y aprender nuevas estrategías.
  4. elseif extends the beginning IF statement so that you can have more conditions... Otherwise, you would end up checking any and all conditions one by one which means that more than one can be true.. With an elseif chain.... only one will be true.
  5. I would put the image filenames into a multi-dimensional array <?php if($dirHandler = opendir($images_dir)){ while(false !== ($file = readdir($dirHandler))){ $files[] = $file; } } natcasesort($files); $images = array(); foreach($files as $myFile){ if($myFile == "." || $myFile == "..") continue; $name = explode(".", $myFile); $name[1] = strtolower($name[1]); if($name[1] == "jpg" || $name[1] == "jpeg"){ echo "<div class='thumb'><a href='" . $images_dir . "/" . $myFile . "'><img src='" . $images_dir."/thumb/" . $myFile . "'></a></div>\n"; //Grab year and place filename into multi-dim. list($y) = explode("-", $name[0]); $images[$y][] = $myFile; } } ?> Then loop through images foreach($images as $newDiv) { echo '<div>'; foreach($newDiv as $imgDiv) echo "<div><img src='{$imgDiv}' /></div>"; echo '</div>'; }
  6. I would concat all the relevant fields into one string and use LIKE to match... For instance searchTerm = "something cheap and awesome" SELECT itemID, itemName FROM items WHERE CONCAT('#', itemName, itemDesc, itemField, itemField2, itemField3) LIKE '%searchTerm%' it also wouldn't hurt to replace all your spaces and other non-alphanum charaacters with a percent sign %. Then replace duplicate % signs with one single % sign This way your query will look like this SELECT itemID, itemName FROM items WHERE CONCAT('#', itemName, itemDesc, itemField, itemField2, itemField3) LIKE '%something%cheap%and%awesome%' The biggest drawback is that the longer the searchTerm is, the harder it will be to find a perfect match. You may have to reorganize your CONCAT to have the most relevant fields appear first...
  7. It should just be $row['prod_price'], tablenames are not needed when accessing the result of fetch_array()
  8. put the article id number within the rewrite as well. In other words, RewriteRule /articles/(.*)_article_name /view.php?article_id=$1 [L] The rule of thumb is that unless you are searching for rows that are similar and alike, never search using a string. The purpose of indices is to keep an index. If you know the index number there is not point in searching by the name of the article. It would be like searching through a literal library for a book by its name and not its ISBN.
  9. This only is a dead giveaway, without even looking at your code, that you are not comparing the input password with the database stored password correctly. You say that in order to login successfully you have to use the HASHED (not encrypted) password stored in the database. That can only mean that you are not hashing the input password before making the comparison.
  10. After further inspection of the code [that you] provided, I realize that you are outputting to the browser before your header call. Not to mention that fact that ginerjim pointed out I'll admit, overlooking the noscript tag was an ignorant thing to do, but forgetting to use the tag is pretty ironic. Surely you must have received a header redirect error? Straight from the manual it tells you:
  11. I can't believe I overlooked that!
  12. For one, you can use the HTML tag. Put the button inside it and it will only appear when javascript is not enabled.
  13. He means that in order for $_POST['submit'] to be set, the user would have to click on it. In your case, the form submits on change so it's assumable that no one will ever be clicking the submit button.
  14. $timeVar = explode(":", "02:15:37.5"); $totalSeconds = 0; foreach( $timeVar as $s) { switch( key($timeVar ) { case 0: //Hours --- 3600 secs in an hour $totalSeconds += ($s * 3600); break; case 1: //Minutes -- 60 secs in a minute $totalSeconds += ($s *60); break; case 2: //Seconds.milliseconds 1000 ms in a second list($a, $b) = each( explode( '.', $s) ); $totalSeconds += $a + ($b / 1000) break; } } echo $totalSeconds . " \n"; echo "Rounded up" . ceil( $totalSeconds ) . " \n"; echo "Rounded down" . floor( $totalSeconds ) . " \n";
  15. The biggest question is time. Do you have the time to learn C? If you're just an unemployed teenager who like programming, I would take the free time that you have an learn C. In short, it will not hurt you to know C As Kevin mentioned earlier though, it all depends on your needs. If you're just bored, I would go with C. if you're looking for a language that you can create a certain application with, learn C++ or C# or Java... Think of it like a vehicle. C++ would be your ability to add things to the car. New engine, new stereo system, new alternator, new upholstery , etcetera, etcetera, etcetera... Knowing C would be your ability to tweak of fix these things without even needing a "new" thing. For instance, say your alternator goes but you just happen to know exactly how to take it apart, change the brushes, make new brushes, whatever. Battery goes out and you know exactly which chemicals to get to renovate it. If you get into a fender bender and part of the body of your car is ripped off, leaving a gaping whole, then you would how to weld some old metal to the point that it looks brand new.
  16. $typecount should be $typeCount variables are case-sensitive. So, while( $row = mysqli_fetch_array($typeCount)) Barrands suggestion is the most ideal and most flexible solution. It only requires though that you re-organize your table structure. If you are willing to do that, then I would definitely go for it. If you cannot, then reference my above solution.
  17. Why not? If you have the time to accomplish such a thing then do it rather than daydream about it.
  18. Try using one query instead of five, especially since all of the queries you have are only different in that they have a different type. $typeCount = mysqli_query($con, " SELECT actcaseld, type, encdate, COUNT(*) AS thecount FROM `Stats` WHERE type IN ("Type 1", "Type 2 diet", "Type 2 ADA", "Type 2 ADA and Insulin", "Type 2 Insulin") AND actcaseld='New Client' AND encdate BETWEEN (SELECT bdate FROM `ReportRange` WHERE cf_id=1) AND (SELECT edate FROM `ReportRange` WHERE cf_id=1") GROUP BY type"); That should give you four rows, each with a thecount field of the count. echo "<table border='1' align='center'> <tr> <th></th> <th></th> <th>Type 1</th> <th>Type 2 Diet</th> <th>Type 2 ADA</th> <th>Type 2 ADA + Insulin</th> <th>Type 2 Insulin</th> </tr>\n"; echo "<tr>\n"; while( $row = mysqli_fetch_array($typecount) ) { echo "<td><center>{$row['thecount']}</center></td>\n"; } echo "</tr></table>";
  19. while( $row = mysql_fetch_array($result) ) { //Looking for 2 echo each($row) == 2 ? key($row) : null; }
  20. I went to google and searched for "undetermined entity reference" and the first result, which was the PHP manual, was this 6 years ago To avoid warning message "unterminated entity reference" you may use htmlentities() for escaping supplied value: <?php //... $dom->createElement('name', htmlentities($text)) //... ?> Omit the fact that it shows up at the very bottom of the page. Ctrl+F is your best friend in searching for information.
  21. You are getting the non-object error because of this line echo array_to_xml($xml_page_info,$wall)->asXML(); You have your parameters backwards... According to this line function array_to_xml($student_info, &$xml_page_info) $xml_page_info goes at the end.
  22. Exactly. But they also come in handy for writing source code for things such as email headers. By putting \r\n after each mail header you allow sendmail to distinguish the characteristics of that message and display them accordingly.
×
×
  • 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.