Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

Shane McC
Shane McC
3,005 Points

Schema Markup, What am I doing wrong?

Hi Everyone,

I added schema markup to my website. I use the Google Structured Data Testing Tool and it's saying I don't have any microdata schema markup?

My syntax is below. What am I doing wrong?

echo '<center>';
echo "<table id='message' border='1'>";
echo "<thead>";
echo "<tr> <th>Dealership</th> <th>Address</th> <th>State</th> <th>City</th>    <th>Zip</th> <th>Phone</th> <th>Website</th> </tr>";
echo "</thead>";
echo "<tbody>";
$sql2 = mysql_query("SELECT DISTINCT dealership, address, state, city, zip, phone,     website
FROM dealers
WHERE (state = '".$state."')
AND (approve = '1')
ORDER BY RAND()");

while($row = mysql_fetch_array($sql2)){
$dealership = $row["dealership"];
$address = $row["address"];
$city = $row["city"];
$zip = $row["zip"];
$phone = $row["phone"];
$website = $row["website"];

$needle = 'http://';
$website;

if (!preg_match("|^http://|", $website)){
$website = $needle.$website;
}

echo "<div itemscope itemtype=\"http://schema.org/AutoDealer\">
    <tr>
        <td><strong><span itemprop=\"name\">$dealership</span></strong></td>
        <td><span itemprop=\"address\">$address</span></td>
        <td><span itemprop=\"addressRegion\">$state</span></td>
        <td><span itemprop=\"addressLocality\">$city</span></td>
        <td><span itemprop=\"postalCode\">$zip</span></td>
        <td><span itemprop=\"telephone\">$phone</span></td>
        <td><span itemprop=\"url\"><a href=\"$website\">Click Here</a></span>     </td>
    </tr>
   </div>"; 
}
echo "</tbody>";
echo '</table>
</center>'.'<br>';
?>

The above syntax would produce this

<center>
<table id='message' border='1'>
<thead>
<tr> 
<th>Dealership</th> <th>Address</th> <th>State</th> <th>City</th> <th>Zip</th>     <th>Phone</th> <th>Website</th> 
</tr>
</thead>
<tbody>
<div itemscope itemtype="http://schema.org/AutoDealer">
    <tr>
        <td><strong><span itemprop="name">John Doe Car Sales</span>   </strong></td>
        <td><span itemprop="address">John Doe Highway</span></td>
        <td><span itemprop="addressRegion">Alaska</span></td>
        <td><span itemprop="addressLocality">Anchorage</span></td>
        <td><span itemprop="postalCode">99515</span></td>
        <td><span itemprop="telephone">123456789</span></td>
        <td><span itemprop="url"><a  href="http://dependablecarsanchorageak.com">Click Here</a></span></td>
    </tr>
  </div>


<div itemscope itemtype="http://schema.org/AutoDealer">
    <tr>
        <td><strong><span itemprop="name">Jane Doe Car Sales</span>  </strong></td>
        <td><span itemprop="address">Jane Doe Car Avenue</span></td>
        <td><span itemprop="addressRegion">Alaska</span></td>
        <td><span itemprop="addressLocality">Anchorage</span></td>
        <td><span itemprop="postalCode">99503</span></td>
        <td><span itemprop="telephone">123456789</span></td>
        <td><span itemprop="url"><a href="http://akrto.com/">Click Here</a></span></td>
    </tr>
  </div>


</tbody>
</table>
</center>

1 Answer

Vijay Rangan
Vijay Rangan
7,543 Points

Try looking at the beginning of your php file. It looks like you're missing something. Let me know how it goes.