/    Sign up×
Community /Pin to ProfileBookmark

Converting website to WordPress. Now images from php msql database no longer clickabl

I am converting a traditional website to WordPress for an animal rescue charity so members can have a blog and more easily update various pages. All has gone well but I am stuck on one key aspect. Viewers of the original site can click on a page that will then display pictures and names of all dogs of a certain size awaiting adoption. The dogs’ names and the location of their photos are stored in a database and the photos in a folder. The images are **clickable** so that the user can pick a dog and see more about it on another page. The original site all works just fine – see link [URL=”http://www.famaspain.com/adoption.html”]http://www.famaspain.com/adoption.html[/URL] then please select Small Dogs (for example).

The page view output looks like this – repeated for each dog of course:
`div class=”dog_box” >
<a href=”http://www.famaspain.com/dogfactstemplate.php?name=Bobby”> <p class=”name”>Bobby</p>
<p class=”dog_img”> <img src=”smalldogsphotos/bobby1.jpg” height=”180″ width=”180″>
</p></a></div> `

and the code used to pull the data from the database is:
`<div id=”animalphotos”>

<?php
$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=”http://www.famaspain.com/<strong>dogfactstemplate.php</strong>?name=$name”> <p class=”name”>”.$name.”</p>tr”;
echo “n”;
echo “<p class=”dog_img”> “. $image .” </p></a>tr”;
echo “nt”;
echo “</div>”;
}
echo “<div class=”clear”></div>”;

?>
</div> <!– End Animal Photos –> `

The various classes just specify margins and spacing for a neat two column layout.

OK – so what’s the problem? Well, if I cut and paste the very same code into a WP page and run it I get each dog’s name and image displayed as per the original site – but they are not clickable and the class names are not used to get the right spacing and margins. (Although WP **is** opening the right style sheet for these class statements.)

The page view results also show missing info – the a href and the classes. Here is one example – repeated for each dog:
`Bobby
<img src=”smalldogsphotos/bobby1.jpg” height=”180″ width=”180″>`

The WP version link is: [URL=”http://famaspain.com/wordpress/?page_id=64″]http://famaspain.com/wordpress/?page_id=64[/URL] Again, please view page and select Small Dogs to see the non-clickable images and poorly aligned display.

Since the php, msql, array etc all run OK and every image is displayed I am at a loss to see what is causing the a href and classes not to be picked up.

Can anyone help please – it’s driving me nuts!

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@arjayauthorFeb 16.2013 — OK - found the error. For anyone else who comes looking, the WP plugin I am using to allow php in WP pages requires some changes to the syntax. For example, all instances of <?php must be [code=php] and ?> must change to [/code]. I had done this but missed a further change. All instances of <, or >, must be changed to [, or ], respectively. This I had missed - for example, <p> becomes [p] and so on.

All is working OK now.
Copy linkTweet thisAlerts:
@arjayauthorFeb 16.2013 — OOOps - this should read the normal opening for php should change to [code=php] and the ending for php should change to [/code] which i had done but missed things like <p> must change to [p] etc.
×

Success!

Help @arjay spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...