Jump to content

ialsoagree

Members
  • Posts

    406
  • Joined

  • Last visited

Posts posted by ialsoagree

  1. Sorry, I forgot my "i" above for mysqli_fetch_assoc!

     

    $query = "SELECT u.profile_image FROM users AS u WHERE student_id = $current_student_profile_id";
     
    $result_array = mysqli_fetch_assoc(msyqli_query($link_id, $query)); // You'll have to define $link_id yourself
    
    $actual_image_name = $result_array['profile_image'];

  2. .josh, I mostly agree with your sentiments. I strongly agree the hybrid approach is best.

     

    My statement about preloading was really just to counter that the split second lack of style is some how a bigger inconvenience than reloading the entire page.  ::) Without it, you only have the overhead of writing the javascript along with the rest of the page on each page load.

     

    To me, that's a worthwhile thing to program for user friendliness, but that's certainly up to everyone's own opinion.

  3. @ialsoagree,

     

    No one here is going to agree with you. I think I can speak for everyone that what you are suggesting is a hack solution. Just because you can do something doesn't mean you should. The primary purpose of PHP is the ability to build dynamically driven websites. A typical page can perform hundreds, even thousands, of operations to display a single page. Having a simple piece of logic to include a link for the style sheet as per the HTML standards is trivial.

     

    I don't disagree, you obviously don't understand what the OP was asking.

     

    Allow me to explain the problem, and why javascript IS the correct solution:

     

    You have a webpage that lets the user change the way the page is displayed. There are buttons to make that change.

     

    Is it better to:

     

    A) Form a new HTTP request, have PHP requery the database, perform all it's if/thens, write a new page, and then send that to the browser.

    B) Have javascript update the page, and save the change to a cookie.

     

    If you don't choose B, you are doing it inefficiently.

     

    Sorry, but it's you who are doing a "hack" solution.

     

    Maybe there is a break in how we are all understanding the issue. For me, giving the user the ability to switch the stylesheet is something the user will do one time and then should propagate to all subsequent page loads. Having that change happen instantaneously on the page which they select it is not something that adds a lot of value in my opinion.

     

    Then your opinion and mine vary GREATLY.

     

    I cannot, under any circumstances, imagine a scenario in which it's better to create 2 HTTP requests for something that only needs 1, query the database twice for a situation that only needs 1 query, and create 2 history files in a browser (1 correct, 1 wrong) for a task that only needs 1.

     

    Mean while, my solution has no down side. Because, as I pointed out, you can still load the correct page using PHP on the first try.

     

    You are welcome to disagree with me, but please don't tell me javascript is not used to change front end content, or that using it to do so is a "hack" solution.

     

    If that's what you think, you need to learn more about javascript.

  4. If the default style is X and then every time a page is loaded javascript has to run to change it to Y, that isn't "preloading" content. If you use PHP it's much faster.

     

    Sure, except the browser has a cache, therefor defeating the need to "preload" a CSS file you've already loaded.

     

    Actually, that's entirely besides the point. Why can't your PHP file check for a cookie on it's own?

     

    Even if you do that, it's still faster to have the switch of the CSS file done by javascript.

     

    At this point, you're just nit picking, and you're not even doing a good job of it.

     

    Edit 2: Actually, now that I think about it, you could even have Javascript choose which file to load by first checking the cookie, and if there is none, loading the default. There's really a lot of solutions to this "problem."

  5. So what you're saying is on every page load, javascript will have to check for a cookie, and then change the sheet.

     

    Just like PHP would, yes.

     

    In fact, javascript can make that change arguably faster than PHP can once the file is cached (and it will be cached once you load it for the first time, which if that involves a switch, will favor javascript by a second or more depending on how long it would take the server to process the request using PHP).

  6. He never stated that he wanted the users themselves to be able to choose, only that he wanted 3 different layouts (for three different medias).

     

    I've already pointed out why this is wrong:

     

    I am currently redesigning a site and am looking at introducing a style switcher to offer two or three varieties.

     

    Say for example I want 3 designs...

     

    1. Desktop version which contains the title and content for 10 news items.

    2. Desktop version which has a slideshow at the top and the title only for 5 news items

     

    Please <mod censor>.

     

    PHP is the over complication. You're trying to do a server-side change of front end content that javascript is entirely able to handle itself.

     

    By the way, if cookies are disabled, unless there's a login feature or the OP wants to save the selection via IP, there's no way to save the selection anyway.

  7. So, when you save it in a cookie, are you then saying that on the next page load, you would load the page then use JS to change the sheet, or have PHP access the cookie to change the sheet?

     

    Neither.

     

    When the user makes a selection: update the HTML/CSS and save that selection in a cookie using javascript.

     

    If the user changes pages, reloads, whatever, it's saved in the cookie, you're all set.

     

    If the user wants to change back, simply update the HTML/CSS again, and save the selection in a cookie using javascript.

     

    You can do this as much as you want, no page loads, no queries to the database, no http requests (unless it has to load a css file).

     

    This is the most efficient way to solve this particular problem, it is why javascript exists.

  8. User loads page.

    User selects new style, using javascript.

    User clicks on link.

    User sees old style sheet.

     

    Do you see the problem with using only javascript now?

     

    No, because I thought ahead:

     

    Just have the javascript change the HTML of the page to fit the appropriate style, and then save their current selection in a cookie.

     

    It helps to read the thread before commenting.

  9. But they do it without javascript. You don't need to and probably shouldn't use JS for this.

     

    :facewall:

     

    You don't need to, no. But if you want to make client side changes to the layout of the page, you're going to have a tough time convincing someone who knows their stuff that JS is the wrong solution.

     

    Please, tell me what is the benefit of calling multiple database requests instead of just 1 request, in order to change the layout of the page? That's what the PHP solution is.

     

    The javascript solution is: no new pages load, no extra database queries, easier for the user.

     

    If that's the wrong solution, I'll take the wrong solution as the programmer or user any day.

  10. When it comes to desktop vs mobile, you do that by having two separate stylesheets and using the media parameter

     

    Agreed, doesn't help you when you want to switch between multiple desktop layouts, just like the OP stated, however:

     

    I had seen that before and had a browse through but I don't think it covers what I am trying to do.

     

    Say for example I want 3 designs...

     

    1. Desktop version which contains the title and content for 10 news items.

    2. Desktop version which has a slideshow at the top and the title only for 5 news items

    3. Mobile version which has the title for 10 news items

     

    Which gets back to my original point: changing the layout of a webpage is most efficiently done using javascript, that's why it was made in the first place.

     

    :facewall:

  11. If you don't really care about the bandwidth usage, you don't even need any PHP to accomplish what you want. Just put display: none on the elements you don't want to show.

     

    You're incorrect.

     

    You need to read what the OP asked. He specifically stated he wants to offer users the ability to switch between page layouts. Without PHP (or another backend programming language) that's not even possible. Javascript can handle that at the front end, but I agree, it is not the only solution, and not the best if MargateSteve isn't familiar with Javascript.

     

    MargateSteve, your decision to use PHP is perfectly fine and will work great.

  12. You missed a little bit of my code when you copied. Your code is:

     

    if(!copy($tmp_name,$temp_path_of_uploaded_file))//had to leave original because $value not yet set...
              {
                 $errors .= '\n error while copying the uploaded file';
              }

     

    It needs to be:

     

    if(!copy($tmp_name,$temp_path_of_uploaded_file))//had to leave original because $value not yet set...
    	    {
    	    	$errors .= '\n error while copying the uploaded file';
    	    }
    $path_of_uploaded_file[] = $temp_path_of_uploaded_file;

     

    You're missing $path_of_uploaded_file[] = $temp_path_of_uploaded_file;.

  13. Your radio buttons need to have a value:

     

    <input type="radio" name="radioButtonName" value="someValue" /> someValue <input type="radio" name="radioButtonName" value="someOtherValue" /> someOtherValue

     

    Which value is selected will be stored in $_POST['radioButtonName'] in this case.

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