Better way to retrieve data from MySQL table?

Hello,

I’m using the following code to create pages:

[code]<?php
include(“dbinfo.inc.php”);
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( “Unable to select database”);
$query=“SELECT * FROM table WHERE id=’$id’”;
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();

$i=0;
while ($i < $num) {
$id=mysql_result($result,$i,“id”);
$title=mysql_result($result,$i,“title”);
$content=mysql_result($result,$i,“content”);
?>

<? echo "$title"?> <? echo "$content"?> <? ++$i; } ?>[/code]

It seems, however, that page content is not being indexed by google (or server stats). For example, google will find page.php but not page.php?id=1.

Is there a better way to retrieve data from a MySQL table?

Thanks,
Robert

Google uses spidering techniques to index a website’s pages. Do you have any links to page.php?id=1 on page.php or on any other accessible (and indexed) page on your website?

Hey Zyppora,

I have links but they are written out on the page like "http://www.domain.com/page.php?id=1."

I JUST realized that this doesn’t help google too much because they like words to be the link not just the link itself.

Sometimes the simplest things mess me up ;)

Thanks for the reply.

Just out of curiosity, is there a better way to pull info (longtext HTML content) from a mysql db to display on a page? Looking at wordpress’ code, i don’t see a lot of “echos.”

Thanks,
Robert

I’m not familiar with wordpress, but I know most CMS systems use templating to display their output. Echo and print are the basics for sending output to the client, but there are other ways to do so. I consider a database to be suitable for storing large chunks of text though.

Sponsor our Newsletter | Privacy Policy | Terms of Service