I have (following various tutorials) made a simple page (or two) that writes to the database, reads from the database and gives it a link such as page.php?id=1, using the ID in the database.
The problem is, filling metadata tags doesn’t happen. I tried placing the PHP above the metadata tags (not sure if that helps?) but it still doesn’t seem to get the data in time.
Here is my code:
Any tips to improve it in other ways as well are always appreciated
[php]
<?php $username="dbuser"; $password="dbpass"; $database="dbname"; $table="data"; $localhost="localhost"; $_SERVER['QUERY_STRING']; mysql_connect($localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM $table WHERE id='$_GET[id]'"; $id="$_GET[id]"; $result=mysql_query($query); $num=mysql_num_rows($result); $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $text=mysql_result($result,$i,"text"); echo "ID: $idLink: $text
"; $i++; } mysql_close(); ?> <?php $text ?> <?php echo "Database Output
";
?>
[/php]As you can see I tried inserting the text variable as the title as well, which didnt work.
Thanks for your help