- This topic has 3 replies, 2 voices, and was last updated 8 years, 6 months ago by
Craig Nicholson.
-
AuthorPosts
-
March 14, 2015 at 3:30 am #86651
Craig Nicholson
Hi all
I have been trying for 2 days now after google searching forums and feel this is the best place to put my problem that hopefully someone can help me with
i am trying to write an sql script to query my database and get the results into a table.
but it doesn’t seem to work
the table headings appear but everything from the first <?php tag shows on the screen
this is my script
<html>
<head>
<title>Last 10 Results</title>
</head>
<body>
<table>
<thead>
<tr>
<td>Property Image</td>
<td>Property Description</td>
<td>Availability</td>
</tr>
</thead>
<tbody>
<?php
$connect = mysqli_connect(“db567706584.db.1and1.com”, “dbo567706584”, “<i would put password here>”, “db567706584”);
if (!$connect) {
die(mysql_error());
}
mysql_select_db(“Properties”);
$results = mysql_query(“SELECTProperty Title4HTML
,Image Tag
FROMProperties
,Available
WHEREProperty Available Flag
=Flag
ANDProperty Available Flag
= ‘2’”);
while($row = mysql_fetch_array($results)) {
?>
<tr>
<td><?php echo $row[‘Property Image’]?></td>
<td><?php echo $row[‘Property Description’]?></td>
<td><?php echo $row[‘Availability’]?></td>
</tr><?php
}
?>
</tbody>
</table>
</body>
</html>does any one know why my results are not coming back?
thanks for any help
March 14, 2015 at 3:54 am #86666Craig Nicholson
also to note i have placed this code in the GP Hooks section under wp_head
<?php
$host_name = “db567706584.db.1and1.com”;
$database = “db567706584”;
$user_name = “dbo567706584”;
$password = “<the password>”;$connect = mysqli_connect($host_name, $user_name, $password, $database);
if (mysqli_connect_errno())
{
echo “Failed to connect to MySQL: ” . mysqli_connect_error();
}
?>March 14, 2015 at 10:54 am #86872Tom
Lead DeveloperLead DeveloperHmm, I’m not a big MySQL guy, but you should try posting over at stackoverflow: http://stackoverflow.com/
It’s the best place for code questions and you should have someone answer you pretty quickly.
Sorry I can’t be more helpful!
March 17, 2015 at 10:01 am #87904Craig Nicholson
issue has been resolved:
https://wordpress.org/support/topic/sql-results-into-html-table?replies=11#post-6703080
-
AuthorPosts
- You must be logged in to reply to this topic.