Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by ginerjm

  1. When you talk about the user changing the food selection, why is that new choice not part of your database already? If you are going to 'offer' it as an option, why is it not listed for the user to select in the first place? That would solve what appears to be a big problem at the moment.
  2. ginerjm

    Extract Data From JSON Using PHP

    Can you NOT read the manual???
  3. ginerjm

    Strange query behavior

    Or if it's a one-time process to create the table, just use the host's phpmyadmin tool to create the table and ensure that it is done correctly right in front of you. THEN write your script. Perhaps use cut/paste to save the input you use in that process in a notepad window until you get it correct or while experimenting or even to save it as a txt file once you are done if you think you'll need to re-create it.
  4. ginerjm

    Mysqli - Can You Not Do These Short-Cuts ?

    Under this identity or all?
  5. ginerjm

    Mysqli - Can You Not Do These Short-Cuts ?

    Agreeing with the others I find you annoying. I will probably get a censure for my comment but after just dealing with one of your other posts under one of your other identities I cannot understand why you exist since it is obviously not for any need to get real tasks done since all you do is ask stuff that YOU SHOULD ALREADY KNOW if you had any gumption. PS - There are no 'shortcuts' in php. Stop using that term. Try and learn that.
  6. ginerjm

    issue with array_unique

    If it is already stored nicely in a db, why try and re-create the wheel with an array? Modify your table structure to add a couple of needed fields that you are trying to utilize in an array and work with that.
  7. ginerjm

    Problem with quotation marks

    It appears to me that you have an extra double quote here: ("' . $image . '");" It also appears that you are closing a non-existent div here: </div> <div class="column-content"> and that you have a hanging div open here: <div class="video-description"> <p>' . $description . '</p>' as well as a missing semi as pointed out already.
  8. ginerjm

    How to make simple if repeat in looping?

    I may be missing something but I'll submit this: $x = $lebar - 40; at whatever point in your code you need to make this calculation for the value of $x.
  9. ginerjm

    subtract a month from a date()

    As I had to do, you should contact your hosting support people and TELL them you want your PHP.ini file to indicate the timezone that you want to default to. Then you'll never have to worry about it again. If they tell you that you can't have it that way, then tell them to give you a FULL copy of the existing .ini file that is in use where you can access it and make the change(s) you need. Be careful though!
  10. ginerjm

    How to make simple if repeat in looping?

    What is "hehe"? Are you joking with us? You've been given a hint as to how to solve it. Twice I believe. How about: $x = $lebar - 40; And yes - you do need $ signs on all of your variables. Come on!
  11. ginerjm

    PHP TIME (NOT TIMEDATE) difference

    This code does the trick. Some examples I found used the floor function which causes a problem with negative differences. The intval() corrects that. $secs_per_hr = 60*60; // example 1 $dt1 = strtotime('07:00:00'); $dt2 = strtotime('15:45:00'); echo "Example 1<br>date1 is ".date('H:i:s a',$dt1). ' and date 2 is '.date('H:i:s a',$dt2).'<br>'; $diff = $dt2 - $dt1; $hours = intval($diff / $secs_per_hr); $minutes = $diff - ($hours * $secs_per_hr); echo 'Ex. #1 - Elapsed time is: ' . $hours . ' hours, ' . ( $minutes / 60 ) . ' minutes<br>'; //echo "Diff is $diff<br>"; echo "<br><br>"; // example 2 $dt1 = strtotime('15:30:00'); $dt2 = strtotime('02:15:00'); echo "Example 2<br>date1 is ".date('H:i:s a',$dt1). ' and date 2 is '.date('H:i:s a',$dt2).'<br>'; $diff = $dt2 - $dt1; $hours = intval($diff / $secs_per_hr); $minutes = $diff - ($hours * $secs_per_hr); echo 'Ex. #2 - Elapsed time is: ' . $hours . ' hours, ' . ( $minutes / 60 ) . ' minutes<br>'; //echo "Diff is $diff<br>"; echo "<br><br>"; // reverse of ex 2 $diff = $dt1 - $dt2; $hours = intval($diff / $secs_per_hr); $minutes = $diff - ($hours * $secs_per_hr); echo 'Ex. #3 - Reverse of #2 is: ' . $hours . ' hours, ' . ( $minutes / 60 ) . ' minutes<br>'; //echo "Diff is $diff<br>"; echo "<br><br>";
  12. ginerjm

    calendar changing

    I assume as much but since I didn't pose the question I wanted to make sure. There is in fact a Georgian calendar but it is outdated except for the use of original names that are no longer in common usage from what I have read. Perhaps our OP does in fact mean the deprecated calendar for some reason.
  13. ginerjm

    calendar changing

    Georgian calendar? Or Gregorian one?
  14. ginerjm

    How to give certain numbers color in PHP

    PS - I goofed in my typing. The classnames that I assigned are mistyped. The span line should use class assignments that match those classes I defined in the CSS code part. As for my misunderstanding the criteria, change the switch code then. The scheme is still the same.
  15. ginerjm

    What PHP should i use? PDO

    PS - as for your topic heading.... You are not choosing a type of PHP when you select the PDO database interface. You are choosing a 'piece' of PHP that connects you to your site's database. It could be the MySqlI extension/interface in many sites or the PDO extension/interface which is recommended very often. (And there may be others.) In any case you would still be using the same version of php that your host has your server setup for. You have chosen wisely though.
  16. ginerjm

    What PHP should i use? PDO

    Personally I have chosen to use the named params in my prepared statements. It avoids future problems when adjustments may be made to your query statement. And it's easier to read. Also I choose to use the array method of passing the arguments to those parms instead of the tedious 'bind' process. in pseudo-code this is what it resembles: $q = 'select a,b,c from tablename where a=:valuea and id=:id'; $stmt = $pdo->prepare($q); $parms = array( ':valuea'=>$a, ':id'=>$id) $stmt->execute($parms);
  17. ginerjm

    How to give certain numbers color in PHP

    PS - since the <font> tag is so-out-of-date, I suggest doing something other than that.
  18. ginerjm

    How to give certain numbers color in PHP

    Since PHP doesn't actually "do" color, I would suggest that you use CSS. Setup a set of colors in your CSS area and then as you loop thru the numbers and create the HTML that will output those, assign a CSS classname. First the CSS <style> .color_1_10 {color:red;} .color_11_20 {color:blue;} .color_21_30 {color:green;} .color_more {color:black;} </style> Now the PHP for ($i=20; $i<=49; $i++) { switch ($i) { case <= 10: $clsname = 'class_1_10'; break; case <= 20: $clsname = 'class_11_20'; break; case <= 30: $clsname = 'class_21_30'; break; default: $clsname = 'class_more'; break; } echo "<span class='$clsname'>$i</span><br>"; } Note that I used a different range of numbers, but I think you get the idea.
  19. ginerjm

    Conversion of text data from $variables issue

    Do you have PHP error checking turned on to see what possible errors there are? If so how about showing us the code that does the query and the code that extracts the two data values from the results in full context so that we may follow it better.
  20. ginerjm

    Is there a proper way to set this up?

    Generate a URL??? Just put the url you need (as demonstrated by Requinix) in place of the relative ones you are putting there now that are NOT being generated.
  21. ginerjm

    Best approach guidance

    Barand has already provided an answer but here's some more contributions, courtesy of a google search: If the value is stored as a DATETIME data type: SELECT YEAR(CURRENT_TIMESTAMP) - YEAR(dob) - (RIGHT(CURRENT_TIMESTAMP, 5) < RIGHT(dob, 5)) as age FROM YOUR_TABLE There is another method that tries to handle the leap years but unless that is extremely important to you it's better left alone for now. In the above the reference to 'dob' is the field in the table.
  22. I agree with Requinix (as any sane forum-reader would) in that cookies are what you need to use for the purpose you just described. That means that to solve your original-posed dilemma you should reference your incoming (from the url query) value using a php variable name. And it may also help to not only check for that url value but the cookie value and assign whichever value you find to the same php variable so that once this startup housekeeping is complete the rest of your code will not need to be altered.
  23. ginerjm

    Best approach guidance

    Back to the PDO portion.... Now that you have identified what you were referring to as using the Object-oriented style of PDO, dare I point out that MysqlI ALSO uses what you so cutely call "shortcuts"? I too do not like the OO method and do very little OO programming. I much prefer the procedural style which I believe you are also referring to when you say 'step by step procedures'. Using the OO method is not a requirement for using PDO. The reason to go with PDO is because it could possibly be the only db interface you will ever have to learn since it was designed to be able to handle many different types of databases and therefore can be used without concerns about the future. Those who used to use the MySQL interface of php have had to go thru struggles to modify their code to switch to either mysqlI or PDO in the last few years. If you are just beginning with your db knowledge-building I highly suggest you go back to the manual and read up on any one of the many functions that PDO provides and notice how each one describes in detail both an OO style and the Procedural style. Just find one good example of using PDO with prepared statements in the procedural style and I think you will see how much simpler it is than mysqlI.
  24. Ok then. More like I thought. So - to the OP - if cookies are your 'must-use' choice you have to realize that the cookie you set NOW is not available until the server is called upon to send a page to your client and only at that time will the cookies that exist AT THAT TIME be delivered to you for reference. If all you want is a user name, why not just set the SESSION array? Or even better just use the var that you create when you grab the url argument.
  25. ginerjm

    Best approach guidance

    Off topic but I am curious as to what you consider the use of "shorthand" in the PDO extension?

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.