Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Posts posted by Zane

  1. Can you emphasize a bit more about your number system?

    As far as keeping the number, you would need to keep those in another table that has a status column called, say, "available".  The value would be 0 or 1.
    Then, you can do a query to get or set the availability of the number. 

    Give said table a "member" id column and you can link the two the tables (members table and the numbers)

    It may help if you described more what this "number" is that must be recyclable.  Lastly, the rule of thumb for a normalized database is to always have a primary key that is just integer auto-incremented, nothing more.  If you want to do further indexing, then add a unique index column for foreign keys to your "number" table.

  2. 20 hours ago, denverdonate said:

    I thought it would be as easy as copying and pasting the text to create a second button but that kills the entire page.

    You provided a screenshot of your desired format: a button next to a button.

    However, you say that it kills the page.  Do you have a way of showing us that?  Even if I use Developer Tools to add a button with copy/paste, it doesn't break the page and there is a button next to a button with no issue.  What part of the page is killed?

  3. Quote

    simplexml_load_file->xpath "returns an array of SimpleXMLElement objects"


    So using the syntax $path->name will not work and will throw such an error

    $simplexml_load_file returns one SimpleXMLElement


    But why even use xpath()?  You could just do this.

    $string = <<<XML
    <?xml version='1.0'?> 
                <lat>2nd LATITUDE</lat>
                <lng>2nd LONGITUDE</lng>
    $xml = simplexml_load_string($string);
    $o = $xml->result->geometry->location->lat;
    echo $o;
    If you wanted the second result instead, you'd treat it like an array
    $xml = simplexml_load_string($string);
    $o = $xml->result[1]->geometry->location->lat;
    echo $o;



  4. I completely agree with Barand.  There is definitely a more efficient way of doing this, but it is your choice to keep doing it this way.  You could at least set up a sandbox/staging version of your site and practice with different approaches, but that's just me saying things.

    In any case, we need more information:

    What does your table schema look like?

    What kind of output are your receiving?

    What do the arrays look like once you've looped through everything?

    Why aren't you just exploding on the comma?  

    Step by step, what is going on here.  Echo it all out and show it to us.  We only have a snippet of your code and very vague output.  I completely understand the concept of the format Google Product Feeds is looking for.  You want the id of the product to be the ID in the database concatenated with a "-" and the size number.  You also want to maintain that id before concatenating and use it for your item_group_id.  Rather than just slapping a snippet of code on here, please walk us through the whole process.  Without any substance, there isn't really a question, is there?  GIGO is what they call it.  Your answers will only ever be as good as the question you start with.

    Here's a snippet of code I like to use for debugging, which would definitely help you out in improving your question.

    echo "<pre>", print_r($data, false), "</pre>";

    $data can be anything, a string, an array, an object, a boolean, it doesn't matter.  print_r's first argument is expected to be mixed.


  5. I would make students[modules] an array of module objects instead of an associative array with numbers in quotes.

    var data = {
        "students": [
                "name": "Eric Smith",
                "modules": [
                        "id": "COMP40003",
                        "name": "Software Development",
                        "result": 80
                        "id": "COMP40001",
                        "name": "Digital technologies",
                        "result": 71
                        "id": "COMP40004",
                        "name": "Web Development",
                        "result": 47
                        "id": "COMP40002",
                        "name": "Networking Concepts and Cyber Security",
                        "result": 0
                "name": "Student Two",
                "modules": [
                        "name": "Module 1",
                        "result": 44
                        "name": "Module 2",
                        "result": 5
                        "name": "Module 3",
                        "result": 34

    And then loop through it using the native array function forEach()

            console.log(j.name + " " + j.result);

    Eric Smith
    Software Development 80
    Digital technologies 71
    Web Development 47
    Networking Concepts and Cyber Security 0
    Student Two
    Module 1 44
    Module 2 5
    Module 3 34


  6. Perhaps you should re-phrase your question because, obviously, the solutions given to you aren't what you're looking for, as you've pointed out.

    If you're simply trying to increment the ticket id/number by one every time a ticket is added to the table, then the above solutions are what you need.  From the code you provided, it almost looks as if you're trying to place the current count of tickets purchased at the time of the new ticket insertion.  For instance, George buy 5 tickets and at that point in time there had already been 80 tickets sold, so you put 80 + 5 to put in that column.  Or, are you just trying to store information in a table all by itself which contains nothing but calculated values that you could have created within the query, but you want to create those values manually?  Please, rephrase your question and don't just dismiss legit solutions because you don't think they'll work.  Explain why they won't work before you just shrug off the efforts of the volunteering experts here.

  7. So, it sounds like what you're after is custom attributes

    User A has a hypnotism rate of 45 neurons per second, and a clairvoyance rating of 5 / 10.
    User B has a rank of 3 of understanding of quantum physics and a shoe size of 25 and a half meters.
    User C has fourteen years worth of towel folding experience
    User D can eat twenty three beer battered brauttwerst in 48 seconds.

    Am I getting closer to what you're talking about?

  8. First of all, PHP and HTML are two separate things altogether.  PHP is typically used to generate HTML.  No matter what language you use, when you load a page in a web browser it's source will be pure HTML (and/or even JavaScript).

    In PHP, the way to preserve a session on every page is to call this function before the first time that you use any $_SESSION variable or anything session related.


    There's no "html page" or "php page".  There is just a file that a browser reads the best it can depending how the server reads the extension of the file.  So, in order to accomplish the problem of "keep my users logged in on an html page", you need to have PHP file that checks for the session's existence and resumes it if it exists.  If it doesn't exist, then it starts one.   Correct me if I'm wrong, but I get the feeling when you refer to a "php page", you're referring to the extension of the file ..?

    mypage.html vs mypage.php


  9. From what I understand so far, you're wanting to keep up with car parts, no?  I'm not an auto expert or anything, I'm just trying to get a feel for what exactly you're aiming for here.  Either you're trying to keep a record of engines, engine parts, and just auto parts in general, and you're wanting to be able to link certain parts to the cars/autos they're available/compatible with,... or, you're just keeping up with a list of cars and what motor(s) they have/had for e.g a car lot where car salesmen sell cars and keep up with the inventory.  Or, perhaps, you're working on a use case catered to mechanics who fix cars and want a history of all of the parts this car has every had in its lifetime.  Anyway, it'd help to explain what you're trying to accomplish.

  10. 1 hour ago, SaranacLake said:

    So it sounds like you think the use-case I described above is okay.

    Yes! Especially since you're not wanting to use JavaScript, it's as simple as putting links to the same php file but with a query parameter for the category.  If you'd use JavaScript, you could do some AJAX magic and just change a portion of the page to reflect the category clicked.  That's a bit more involved, though.

    • Like 1
  11. 17 minutes ago, SaranacLake said:

    Not gonna answer my questions, huh?

    What?  A bit impatient, aren't ya.

    18 hours ago, SaranacLake said:

    What I have been asking about is how to make it so a user can click on different "categories" in a side menu and see the related products in that category/group/whatever.

    First, you make a PHP script that grabs all products from a database where the category equals whatever is in the GET parameter in the URL


    Then, you loop through the results and display them however you want.

    It's also possible that a product is part of multiple categories.  In that case, you'd have a table just for categories, and then another table linking the columns to products, and then the products table.

    There's really no cut-and-dry answer here.  You simply grab the category id or name or whatever identifier you want to use and grab the products from your database based on that category id.

  12. 17 hours ago, SaranacLake said:

    what do you call that area of the website?

    There are a handful of those kinds of pages.

    Category Listing Page (CLP)

    Typically, this is more or less what you'd call a homepage for a particular category where you explain what it is, provide pictures of different products in that category, etc...  Typically, the CLP might have a few featured products, but doesn't show them all.  Then again, it's up to you.  A lot of times you'll find videos on this page, or some kind of introduction to the category.  

    Example:  https://www.burpee.com/organics/

    Product Listing Page (PLP)

    This is a page listing your products.  It's named as a Listing Page because the products are displayed in a list.

    Example: https://www.burpee.com/herbs/container-herbs/#sz=24&start=0&type=list

    Product Grid Page (PGP)

    Whereas, on a product grid page, they are displayed in what you'd described as a matrix.  For instance, 5 columns of products, each row containing 5 product squares.

    Example: https://www.burpee.com/herbs/container-herbs/#sz=24&start=0&type=grid


    From then on out, you just have your Product Detail Page (PDP) for products that were clicked on the PLP/PGP/CLP

  13. 2 hours ago, SaranacLake said:

    Right now, I am trying to lay out (and ultimately code) a web page that looks like the link I pasted above

    Sounds like you need to layout your design first and come back with code that you've tried already.  You did mention that you have a history with PHP, so gives us a PHP problem to solve.  

    2 hours ago, SaranacLake said:

    How does that sound?

    I'm not sure what you're asking.  Are you asking if your thoughts sound good?  Or, are you asking us what kind of effort it sounds like it would take to do such a task?  Or, are you just asking how to do it all?  So far, all I understand is that you want to show a list of products and filter it by category.  You're also not using JavaScript, so you want these links to refresh the page when clicked and load a page with a pretty url like mysite.com/movies using mod_rewrite.  It all sounds ... like the fundamentals of an ecommerce website really.  List of products, add to cart, checkout, purchase, etc...  Yet, you're only focused on the product listing part at this point and are simply asking how a list of products sounds.

  14. 11 hours ago, SaranacLake said:

    Does the use-case i outline above sound like a reasonable approach?

    Yes.  It's not only reasonable, it's common practice to do it that way (with mod_rewrite).  Off the top of my head, I can't think of any other way to accomplish this.

    • Like 1
  15. Seems like you're only real question is whether or not you're going about this the right way.  While there isn't a "right" way, per se, to do something, this is probably the most popular way.  You didn't provide code, so I assume you've already set things up this way, no?

  16. 1 hour ago, ajetrumpet said:

    it has no id attribute

    Why not?  That's the whole point in having an id attribute, to identify it easily.  Instead of having to use


    you can use


    To get you textarea to populate, though, you'll need to listen for the click of the anchor tag, or modify what happens when it's clicked.

    <a href="#nowhere" id="anchor">Click HERE</a>
    <textarea id="LOOKUPADDRESS"></textarea>
    	var t = document.getElementById("LOOKUPADDRESS").innerText = "<?php echo $col; ?>";

    I haven't tested any of this code, so copy and paste at your own risk.

  17. 6 hours ago, SheenLim08 said:

    I did that at the end of the <script> tag

    Ah, I completely missed that.  I do agree with everyone else though.. Why are you not using a framework for this?  With jQuery, you can do a POST request as easy as this:

    jQuery.post('urlpost.php', { 'url':'facebook.com' });

    Not only that, but you can add a callback function to do stuff with the data returned.

    jQuery,.post('urlpost.php', { 'url':'facebook.com' }, function(data){ console.log(data); });

    Why go about it in the most antiquated way?

  • 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.