Site logo

Archived topic

SQL Script output results into table

3 replies · Started by Craig Nicholson on March 14, 2015

Viewing posts 1–4 of 4

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("SELECT Property Title4HTML,Image Tag FROM Properties,Available WHERE Property Available Flag = Flag AND Property 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

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();
}
?>

Hmm, 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!

This archived topic is closed to new replies.