Announcement

Collapse
No announcement yet.

Load an image in a table

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #31
    Many thanks

    The full display of the database when the box is empty has been resolved in all browsers including IE8 and 9 (IE9 in Emulation Mode - I don't have access to an IE9 browser, unfortunately).


    There is only a tiny little issue. The $searchq; displays the same message be it for an empty box, be it for a non-existent record.

    can it be split so that the empty box returns: you did not enter anything; try again!

    ?

    EDIT

    $searchMsg = 'Please enter at least 3 characters';
    This message nevr appears in IE8 or IE) which is where it would be needed.

    ANOTHER EDIT

    I have a much bigger problem now!

    The whole effort is directed at a link in the logo.

    If the logo is that of Accor by pressing the logo the user gets redirected to their website, and the way I envisaged it doesn't work!

    <tr>
    <td><a href="/request/index.php?id=$chain"><img src="<?php echo $image; ?>" alt="" /></a></td>
    <td><?php echo $chain; ?></td>
    <td><?php echo $country; ?></td>
    <td><?php echo $city; ?></td>
    <td><img src="<?php echo($top == 'y') ? "Gre.png" : "Red.png"; ?>" alt=""></td>
    <td><img src="<?php echo($medium == 'y') ? "Gre.png" : "Red.png"; ?>" alt=""></td>
    <td><img src="<?php echo($low == 'y') ? "Gre.png": "Red.png"; ?> " alt=""></td>
    </tr>

    It's being redirected to my home page.

    Everything else if no consequence if this does not work

    Help....

    Thank you



    Many thanks
    Last edited by qim; 12-03-2015, 05:41 AM.

    Comment


    • #32
      hi qim,
      can you be more specific please.
      Is this for IE only (where the HTML5 validation doesn't work)
      So, you don't enter anything in the search box in IE, are you seeing the message 'Please enter at least 3 characters' on the results page?
      What message are you seeing if your search term returned 0 results?

      Edit (to keep up with your edits!)
      What is this page supposed to do - request/index.php?
      Last edited by Reiss; 12-03-2015, 05:47 AM.

      Comment


      • #33
        Edit (to keep up with your edits!)
        What is this page supposed to do - request/index.php?

        Sorry! One disaster after another!

        When you press the logo link you are supposed to go to the website of the hotel chain, in this example Accor.

        Because affiliate link codes are so extensive I use an internal redirect to a folder that keeps all the codes that are accessed by the a reference to them, in this case "Accor"

        Have a look at this page, please
        http://pintotours.net/Europe/Spain/NovotelBcn.html

        When you click on the logo at the bottom of the page you get sent to the hotel's website

        The code for that is

        HTML Code:
        <a id="logo-close" href="/request/index.php?id=NovotelBarcelona" target="_blank">
        I thought from the beginning that I could simply use the $chain instead of the code for the hotel, in the case above, NovotelBarcelona

        If I can't get this to work I have to simply abandon the page with all the work, mine and yours!

        But there maust be a way. Maybe I'm just coding badly; maybe it needs an echo or something...

        Sorry, one more EDIT...

        Let me explain further, if this was not a php Query page the code for in the table for the Accor would be

        <td><a href="/request/index.php?id=Accor"><img src="<?php echo $image; ?>" alt="" /></a></td>

        but if you bear in mind that in the "invented" Brussels page there are 3 chains, the code inside of the <td></td> must reflect the actual hotels chain, meaning that each row will have a different code which can only be got from the content of $chain.

        So, for this to work $chain must be put in there to connect to the request folder

        In that case here goes another EDIT

        I think this is very close to what I need

        http://stackoverflow.com/questions/3...rlink-in-table
        Last edited by qim; 12-03-2015, 07:07 AM.

        Comment


        • #34
          simple solution would then be to add an additional column in the database, maybe called 'hotel_code' and then add that to your query to use in the link.

          Comment


          • #35
            add an additional column in the database, maybe called 'hotel_code'
            But that is already there. The hotel code is the same as the $chain, or am I missing something?

            The code for Accor in the 'request' folder is "Accor"

            All other hotel chains will have their code matching the entry in the database for "Chain"

            Meanwhile, I realized that the reason why at the moment the Accor logo is redirecting to my home page, is because the 'request' folder has an entry to redirect to the Home page, if the access code is incorrect or non-existent.

            So, the code inside the <td> is getting as far as the folder but in a format that it can't understand; what it needs to see
            is a naked 'Accor'.

            EDIT

            What is wrong with this?
            <td><a href="/request/index.php?id='.$results['chain'].'"><img src="<?php echo $image; ?>" alt="" /></a></td>

            If there is a way of finding out the format of the code that is reaching the 'request' folder, then I could change it there accordingly.
            Last edited by qim; 12-03-2015, 07:44 AM.

            Comment


            • #36
              Originally posted by qim View Post
              What is wrong with this?
              <td><a href="/request/index.php?id='.$results['chain'].'"><img src="<?php echo $image; ?>" alt="" /></a></td>

              If there is a way of finding out the format of the code that is reaching the 'request' folder, then I could change it there accordingly.
              $results['chain'] is an array called $results with an key called chain, I'm pretty sure that is not what is defined on your page, judging by what you've said,
              Code:
              <td><a href="/request/index.php?id='.$chain.'"><img src="<?php echo $image; ?>" alt="" /></a></td>
              should work fine.

              To see what is being passed to request/index.php, add the following to the top of the page -

              PHP Code:
              echo $_GET['id']; 
              that will show you what is being passed via the GET
              Last edited by Reiss; 12-03-2015, 10:20 AM.

              Comment


              • #37
                Hi

                Code:
                <td><a href="/request/index.php?id='.$chain.'"><img src="<?php echo $image; ?>" alt="" /></a></td>
                I'm afraid it didn't work...


                Where exactly do I put the
                HTML Code:
                echo $_GET['id'];
                Sorry...
                add the following to the top of the page -
                the page is at

                http://pintotours.net/TEMP/FINAL/input.html

                Thanks
                Last edited by qim; 12-03-2015, 09:18 AM.

                Comment


                • #38
                  echo $_GET['id'];
                  I put it above and below the opening <?php and did not see anything...

                  Where should I look?

                  EDIT...

                  I looked at the page in FF browser Console and found this:

                  GET http://pintotours.net/request/index.php?id=%27. [HTTP/1.1 302 Moved Temporarily 0ms]
                  What does it all mean?
                  Last edited by qim; 12-03-2015, 09:27 AM.

                  Comment


                  • #39
                    Hi Reiss

                    I don't want to keep you any longer and I'm sure you have nappies to change...

                    If you think of a way to solve the redirect, let me know. I have been thinking of your suggestion to create a new column in the database but don't see how that could work. Some of the affiliate links are enormous, e.g.



                    So, I would need a code, and the actual link would hve to be in a file, just like it is now, Maybe I am not seeing things properly, though,

                    I left the other matter pending and if you don't mind I'll answer now:

                    Is this for IE only (where the HTML5 validation doesn't work)
                    So, you don't enter anything in the search box in IE, are you seeing the message 'Please enter at least 3 characters' on the results page?
                    What message are you seeing if your search term returned 0 results?
                    Everything's workinf fine in all browsers. I was only referring to the messages. There is one saying that there were no matching records:fine.

                    Then, there is another that should state that the box was left empty, but in fact repeats the one about no matching records. That only happens with ie 8 and 9 because in the other browsers it never gets to that stage. Although I thought that th code below would prevent the box from doing anything until something was typed in

                    This is all minor because the main problem was the whole database displaying on empty boxes. That has been cured, I believe and hope.

                    Thank you very much for your patience
                    Last edited by qim; 12-06-2015, 04:22 PM.

                    Comment


                    • #40
                      can you post your code for request/index.php

                      Comment


                      • #41
                        EDITED. Sorry
                        Last edited by qim; 12-06-2015, 04:23 PM.

                        Comment


                        • #42
                          hi qim,
                          I think you've really overcomplicated things there!

                          Why don't you put the redirects in the database along with the rest of the data and use the redirect URL as the image href? (or am I missing something... 3hrs sleep hasn't got me at my best!)

                          Comment


                          • #43
                            Hi Reiss

                            Why don't you put the redirects in the database along with the rest of the data and use the redirect URL as the image href? (or am I missing something...
                            Do you mean one extra row to place e.g.

                            /request/index.php?id=Accor in front of every Accor record (1000 of them...) and where does the image come in?

                            I discovered that the problem has to do with the headers that arrive in the file and that have an Id that does not correspond to the one in the file. Therefore the request is ignored and redirected to the default home page


                            EDIT

                            Maybe the if-then-else or would work better

                            3hrs sleep hasn't got me at my best!)
                            and how many nappies?


                            Reiss I've been working on something else and it is starting to work. Unfortunately I don't know how to code php...

                            Code:
                               <td><?php echo($chain == 'Accor') ? '<a href="/request/index.php?id=Accor">' : <?php echo($chain == 'IHG') ? '<a href="/request/index.php?id=IHG">' : '<a href="/">';?><img src="<?php echo $image;?>" alt="" /></a></td>
                            The idea is that even though the database will have 5000/10000 records, there are only about 20 hotel chains.

                            So, the code should read if A url1. else ifB url2 else ifC url3 else if D url4 and so one.

                            I've managed to get it to work with 2 but not anymore.

                            I think the reason is that else only works once, and maybe I need to use something else like elseif, or even start with if and test one at a time

                            I will end up with a very long <td> but the problem will be solved until I think of something else

                            Have a look at http://pintotours.net/TEMP/SAFE/input.html enter "Brussels"

                            then if you click on Accor you get their page; if you click on any of the other 2 you get IHG, because I have not been able to add the third. When I do I will carry on adding up to whatever number needed (maybe 20)


                            EDIT

                            Maybe if-then-else would work better
                            Last edited by qim; 12-04-2015, 06:45 AM.

                            Comment


                            • #44
                              Hi Reiss

                              PROBLEM SOLVED

                              The original code was correct except for the inverted commas a nd a thing or two more

                              Look at http://pintotours.net/TEMP/FINAL/input.html Enter "Brussels" (the only way of getting several cahins at the moment) and then click on the images...

                              if you could look at the othe rissue...

                              Comment


                              • #45
                                I was talking about the image URL's on your Results2.php page, actually putting the redirect URL in the image href instead of request/index.php....

                                If you have 20 hotels and 1000's of database entries, then it's a good idea to set up a relational database.
                                So, create a new table called hotel_chains for example, this will contain your 20 chains with a unique ID

                                table - hotel_chains

                                id | chain_name

                                1 | Accor
                                2 | IHG

                                etc
                                and in your chains table, add a new column called chain_id, this will relate to the hotel_chains table, so chain id 1 will relate to Accor, chain id 2 relates to IHG etc.

                                Your query would then use a LEFT JOIN in your query like so -
                                Code:
                                $sql = "SELECT Image, Chain, Country, City, Top as '', Medium as '', Low as '', chain_name FROM Chains 
                                LEFT JOIN hotel_chains ON Chains.chain_id = hotel_chains.id
                                WHERE Country LIKE ? OR City LIKE ?";
                                as you can see, we're not selecting the chain id from the Chains table, rather the chain_name from the hotel_chains table but using the chain_id to link them up.
                                Does that make sense or have I just opened up a whole new can of worms

                                Comment

                                Working...
                                X