Jump to content

MySQL/PHP Help (Not very advanced)


shakethefloor

Recommended Posts

I am creating a page where users submit some text to a mysql database, and it is given an ID, then that ID is used on a page (/link.php?id=10) etc to call up the information, and then the Text and ID from the database are used to fill the META tags of the page, and they are also shown on the page, with a link to "Like" the page on facebook. I have everything working, but i'm pretty sure the code is messy and there's lots of un needed stuff in there, as well as I can't call the information from the database for the META tags, because i need to call the same information to generate the text in the page, and I can't get the text in the page to be where i want it to be, as well as having the PHP to call the information in the place i want (If any of this makes sense!) If anyone can help it would be super appreciated, and if I confused you please ask and I will try explain better :)

 

Page:

 

<?php
$username="USER";

$password="PASS";

$database="DB";

$table="data";

$localhost="mysql3.000webhost.com";

$_SERVER['QUERY_STRING'];

$idurl="$_GET[id]";

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_num_rows($result);


$i=0;
while ($i < $num) {

$id=mysql_result($result,$i,"id");

$text=mysql_result($result,$i,"text");


echo "<h1><a href=\"http://www.website.co.uk/link.php?id=$id\">$text</a></h1><br /><br />";

$i++;

}



mysql_close();

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css" />

<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />

<title><?php echo $text ?> - Title</title>

<meta property="og:title" content="<?php echo $text ?>" />

<meta property="og:type" content="product" />

<meta property="og:url" content="http://www.website.co.uk/link.php?id=<?php echo $id ?>" />

<meta property="og:site_name" content="Title" />

<body>
<div id="topbar">

<div class="outmaincontainer">

<div class="inmaincontainer" style="height: 31px; margin-top: 10px; vertical-align:middle;">

<img src="images/logo.png" style="padding-top:6px; padding-left:1px;" />
</div
>
</div>

</div>

<div class="outmaincontainer" style="padding-top: 41px;">

<div class="inmaincontainer" style="height: 100%;">

<div class="innercontent">


<br />


IFRAME FOR FACEBOOK LIKE GOES HERE
</div>

</div>

</div>

</body>

</html>

 

 

EDIT: OKAY so the <a> tags with the ID and Text vars at the top of the page are meant to be inside innercontent div, but if I place all the PHP there then the ID and Text vars aren't pulled from the database and inserted into the META tags, this is my main problem that needs fixing

thanks!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.