Support » Fixing WordPress » Converting website to WP but images pulled from database no longer clickable?

  • Resolved arjay1


    Successfully converted 20 pages of an animal rescue charity website to WP. But one issue still dogging me. Viewers can click on a page that displays pictures and names of all dogs of a certain size awaiting adoption – pulled from a database. The images are clickable so that the user can pick a dog and see more about it on another page. The original website link is FAMA then choose Small Dogs (for example).

    The original working code to pull the images and names from the database and display them is:

    <div id="animalphotos"> 
    $db_host = '*********';
    $db_user = '*********';
    $db_pwd = '*********';
    $database = '***********';
    $table = "**********";
    if (!mysql_connect($db_host, $db_user, $db_pwd))
    die("Can't connect to database");
    if (!mysql_select_db($database))
    die("Can't select database");
    // sending query
    $results = mysql_query("SELECT * FROM $table WHERE type= 'dog' AND category = 'adopt'  AND  placement='Unplaced' AND size = 'small' ORDER BY name");
    if (!$results) {
    die("Query to show fields from table failed");
    while($results_array = mysql_fetch_array($results))
            $id = $results_array["id"];
            $image = $results_array["photo1"];
            $name = $results_array["name"];
            echo "<div class=\"dog_box\" >\r";
            echo "\n";
            echo "<a href=\"<strong>dogfactstemplate.php</strong>?name=$name\"> <p class=\"name\">".$name."</p>\t\r";
            echo "\n";
         echo "<p class=\"dog_img\"> ". $image ." </p></a>\t\r";
            echo "\n\t";
            echo "</div>";
        echo "<div class=\"clear\"></div>";
    </div>   <!-- End Animal Photos -->

    This works fine and the page source shows for each dog repetitions of this for each dog:

    <div class="dog_box" >
    <a href="<strong>dogfactstemplate.php</strong>?name=Bobby"> <p class="name">Bobby</p>
    <p class="dog_img"> <img src="smalldogsphotos/bobby1.jpg" height="180" width="180">

    Note the page called to display more info is named here as dogfactstemplate.php (in bold above).

    I have recreated the same dog display page in WP to contain the exactly the same code as the php above. The names and images display OK, but the page source only shows:

    <img src=”smalldogsphotos/bobby1.jpg” height=”180″ width=”180″>`

    That is, the images are no longer clickable and the two classes dog_box and dog_image are missing (they set the margins for the displays). However, the stylesheet that contains the CSS for these classes (and a load of other stuff) is present. Here is the link to the WP version FAMA WP – again just click on Small Dogs. You can see that images are not clickable and the layout has changed for the worse.

    Sorry for the long post but maybe you need to see the relevant code. Anyone help me sort out this issue?

    Many thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Update – apologies – had a senior moment there. The images are stored in a folder of course, not a database

    Sorry – been a long day. The images are held in a folder but the dogs’ names and locations of the images are held in a database

    How about this (try)?

    <div class="dog_box" >
    <a href=""> <p class="name"><strong>Bobby</strong></p>
    <p class="dog_img"> <img src="smalldogsphotos/bobby1.jpg" height="180" width="180"> </p></a>

    Krishna – thanks for the suggestion but it did not work.

    However, i have solved the issue. For anyone who comes looking – the problem was my inaccurate use of the php plugin “Allows php in pages and posts”. This plugin requires the normal opening and closing tags for php to be changed to [php] and [/php] which i had actually done.

    But I missed another change that is required: to change <p> to [p] and </p> to [/p] etc. Once i did this, the code ran OK.

    Hope this might help anyone who makes the same mistake as I did.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Converting website to WP but images pulled from database no longer clickable?’ is closed to new replies.