PHP - Meta Tags In Php _get Urls
How do you give pages that are generated using the _Get method it's own meta tags?
Not sure if I'm explaining this properly so allow me to elaborate: When a visitor clicks on an article on my site, they get redirected to a new page (index.php?action=article1) within the original page (index.php). Now, since it's more or less the same page, the meta tags are the same, but I was wondering if there is a way I could make it to where each article has it's own unique tags so when a visitor, for instance, clicks "share on facebook", the title and description of that article appears. Does anyone know what I'm talking about? If so, is there a way to do this? Similar TutorialsHi All, Currently, in my application, my links use index.php?id=14 (or whatever ID it is). Should I somehow encrypt those so the exact ID is not known or is this OK? hello guys, i have a php website, which is: www.hireasunbed.co.uk the middle is like an iframe but im wondering how can i get each catagory have diffrent meta keywords and descriptions. Is this possible? Hello again:] I am wondering where should i put valid doctype <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> and meta tags <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> in a php file like this. Code: [Select] <?php session_start(); // Session starts here if(!isset($_SESSION['username'])) // If there is no session then... { die ("<div align='center'><img src='images/LOGINKITTEN.jpg'/><br /><a href='index.php'><img src='images/Login.jpg'/></a></div>"); // ...Die! } $id = $_GET['id']; ?> <html> <head> <link rel="stylesheet" type="text/css" href="jamcss.css" /> </head> <body> <img src="images/jamspace.jpg" /> <div id="jamcontainer"> <b><a href="main.php">Home</a> || <a href="members.php">Members</a> || <a href="jams.php">Jams</a> || <a href="uploadjamform.php">Upload Jam</a> || <a href="myprofile.php">My profile</a> || <a href="about.php">About</a> || <a href="adminindex.php">Moderators</a> || <a href="logout.php">Logout</a></b> You are logged in as <?php echo $_SESSION['username']; ?> <br /><br /> <?php $connection = mysql_connect("lol.com", "loldb", "lol00") or die ("Could not connect"); mysql_select_db("loldb", $connection) or die("Could not connect"); // mysql query to get the username $query = mysql_query("SELECT * FROM news ORDER BY id DESC"); $numrows = mysql_num_rows($query); if ($numrows!=0) { // fetching data from the database to variable while ($row = mysql_fetch_assoc($query)) { $title = $row['title']; $post_owner = $row['post_owner']; $post = $row['post']; echo "<b>" . $title . "</b><br />"; echo "Posted by <b>" . $post_owner . "</b><br /><br />"; echo $post . "<hr></hr><br /><br />"; } } ?> </div> </body> </html> Hi there. Having a little trouble getting Open Graph working with my facebook like button. I can put text in fine but I want the following variables to be represented in the head information so that I can edit the head data periodically. Would appreciate any help. I've tried "<?php echo $blahblah ?>" which doesn't seem to work. Confirmed that nothing was being pulled by Facebook's linter... Code: [Select] //Variable for Head. $id = '1'; $promo_id = $id; //Change this to be variable with function... $promo_title = "Goody Bag"; $promo_text = cms::string('copy.goody_bag.sub_title'); $promo_image = "/assets/images/goody_bag/goody_bag_small_bg.png";//Change this to be variable with function... $promo_description = cms::string('copy.goody_bag.text'); //These are to be put into the head information but will need to be made variable using either the controller or the iframe.php ?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml"> <head> <title></title> <meta property="og:title" content="Goody Bag"/> <meta property="og:type" content="website"/> <meta property="og:url" content="http://apps.facebook.com/ztoa_dev/like/show_like/1"/> <meta property="og:image" content="http://apps.facebook.com/ztoa_dev/assets/images/goody_bag/goody_bag_small_bg.png?2"/> <meta property="og:site_name" content="Z to A by Sunsilk"/> <meta property="fb:admins" content=""/> <meta property="og:description" content="Blah Blah Blah"/> </head> Hi all, I am looking a developing a script that instead of using something like mysite.com/showproduct.php?id=1 I would like it to appear as mysite.com/php-editor Is their a simple way of doing this? I would still need to pull info from a database so the page would still need to be dynamic, I just want it to appear static! I am used to using the get id function of php, what would the workaround be? would the id be hidden from the url but still usable in a query? I have had a look at the apache mod_rewrite, but quite frankly, I dont understand it! Cheers A few months ago, and a good amount of time before that, I had people telling me to use isset() instead of performing to see if the variable is empty, such as: !$_GET[''] I know the differences in the function and what they do, but when could isset() be used in a situation where it's better/more efficient then: !$_GET[''] I do use isset(), though. hi everyone, did not know what to make the subject, but here is what I want to do: I have a string, which gets returned to me from a linux app on my server, it looks something like this: Code: [Select] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> <TITLE> </TITLE> <META NAME="GENERATOR" CONTENT="OpenOffice.org 3.2 (Linux)"> <META NAME="AUTHOR" CONTENT="Administrator"> <META NAME="CREATED" CONTENT="20110106;14170000"> <META NAME="CHANGEDBY" CONTENT="HOD"> <META NAME="CHANGED" CONTENT="20110522;16540000"> <STYLE TYPE="text/css"> <!-- @page { margin: 0.26in } P { margin-bottom: 0.15in; direction: ltr; color: #000000; line-height: 0.15in; text-align: justify; widows: 2; orphans: 2 } P.western { font-family: "Arial", sans-serif; font-size: 10pt; so-language: en-US } P.cjk { font-family: "Batang", "바탕", serif; font-size: 10pt } P.ctl { font-family: "Times New Roman", serif; font-size: 10pt; so-language: ar-SA } A:link { color: #0000ff } --> </STYLE> </HEAD> <BODY LANG="en-US" TEXT="#000000" LINK="#0000ff" DIR="LTR" STYLE="border: 5.05pt double #000000; padding: 0.67in 0.92in"> <P>I want this and the tags around it, just not the html, head, body and their closing tags.</P> </BODY> </HTML> within the body, the tags are each styled for example: <p style="color: red"></p> so I cannot just get rid of all html, I want to get only all the content within the body tags, but without the body tags obviously strip_tags does not work as i need, I only want to strip certain tags. If someone can help me with this i will much appreciate it. I am asking out of curiosity, how does this problem usually get solved, when using a tag system to sort content, and users enter similar tags. For example: flower and flowers... which means the difference between singular and plural. Judging by other sites which are around, this problem is not solved at all, they simply let you add as many tags as you want and then rank the most used tags, it indeed is a solution, but seems more like a walk-around solution to me. Any ideas how somebody could approach to solve this one? EDIT: My suggestion would be an analysis function, which analyzes the entered tag and then suggests the user that similar tags have been already entered and perhaps he wants to choose one of those which have been already entered. This does work though with a high traffic websites what can happen is the following: php and php5 You can end up with two similar tags which are both widely used though have different meanings to the user base. This one could be solved by simply prohibiting similar tags with little additions or changes, and so to speak "forcing" the user to choose something which is already there. May be a way, though it can turn out as a bad solution as well. Do anyone know how i can put the html tags in the same line as the other html tags? Here's an example: Code: [Select] Images | Link | Delete | Enabled On my code, it break the tags to the new line without put on the same line as the other tags. Here's the code: Code: [Select] [code]<?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'myusername'); define('DB_PASSWORD', 'mypass'); define('DB_DATABASE', 'mydbtable'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($var){ return mysql_real_escape_string(strip_tags($var)); } $username = clean($_GET['user']); $password = clean($_GET['pass']); if($username == '') { $errmsg_arr[] = 'username ID missing'; $errflag = true; } if($password == '') { $errmsg_arr[] = 'PASSWORD ID missing'; $errflag = true; } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; echo implode('<br />',$errmsg_arr); } else { $qry="SELECT * FROM members WHERE username='$username' AND passwd='$password'"; $result=mysql_query($qry) or die('Error:<br />' . $qry . '<br />' . mysql_error()); if(mysql_num_rows($result) > 0) { $qrytable1="SELECT images, id, public FROM members WHERE username='$username'"; $result1=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br />' . mysql_error()); while ($row = mysql_fetch_array($result1)) { echo '<p id="images"> <a href="images.php?id='.$row['id'].'">Images</a></td> | <a href="http://' . $row["links"] . '">Link</a> </td> | <a href="delete.php?id='.$row['id'].'">Delete</a> </td> | <p> <p id="test">'.$row['Public'].'</td>''; } } } ?>[/code] Say I have the following text stored in a MySQL database... Code: [Select] <b>Classic Quote from movie</b> and I retrieve it into a variable called $text, how do I properly echo that so that it keeps the bold tags and actually display the text "Classic quote from movie" in BOLD? I'm doing something wrong somewhere along the line (simply doing "echo $text;") because it displays on the page as... Code: [Select] <b>Classic Quote from movie</b> Instead of... Classic Quote from movie Any info on properly storing and echoing back HTML would be very appreciated. Hello, Ive got many URLs like these which im trying to just get the name for example "Ace Lightning" Quote http://www.wupload.com/file/1374721/Ace Lightning # GBA.rar http://www.wupload.com/file/1374722/Action Man - Robotatak # GBA.rar http://www.wupload.com/file/1374726/Activision Anthology # GBA.rar http://www.wupload.com/file/1374761/Advance Guardian Heroes # GBA.rar http://www.wupload.com/file/1374764/Agassi Tennis Generation # GBA.rar This is my code Code: [Select] <?php if($_POST['newlinks']) { $newlinks = $_POST["newlinks"]; $newlinks = preg_split("/.rar/", $newlinks); foreach ($newlinks as $newlink) { $r_name = substr("$newlink", 36, 100); echo "<strong>Game Name: $r_name</strong> <br />"; } } echo "<form method=\"POST\" action=\"index.php?page=mass-gba\">"; echo "<br /> <strong>Mass Add GBA ROMs</strong> <br />"; echo "<textarea rows=\"16\" name=\"newlinks\" cols=\"84\"></textarea>"; echo "<input type=\"submit\" value=\"Mass Add GBA Links\" name=\"B1\">"; echo "</form>"; ?> This results are like this, I cant understand why it works for the first game but not the second or any after that. Quote True Name: Ace Lightning # GBA True Name: 2/Action Man - Robotatak # GBA True Name: 6/Activision Anthology # GBA True Name: 1/Advance Guardian Heroes # GBA True Name: 4/Agassi Tennis Generation # GBA Is their something I can do in PHP (like some sort of function/config/array etc...) which would make the following process easier (examples appreciated)... I have an .htaccess file where im rewriting urls to seo friendly ones...now in the PHP script is their something I can place for urls are meant to be displayed/linked (like some sort of placeholder) which makes it easier for me to modify the urls within the PHP script, without constantly editing countless php sourcecode to just change the url? Example scenario: Say I had a php file (called submit.php): <?php echo 'Hey! Thanks for submiting the form, <a href="submit.php?form">click here</a> to go back!'; ?> and my rewrite rule for submit.php?form was: /form How would I easily change the url within submit.php without editing submit.php directly? Hi, What is the best way to change: www.mysite.com/product.php?id=1&sort=2&cat=z to: www.mysite.com/1/product-name-here I would need the other variables in the URL (sort & cat...) to also pass through to the new address. Is this an .htaccess change or via PHP code? Any help appreciated, thanks. Can someone help me to generate SEO friendly URLs? I dont want my URLs to be presented like: www.example.com/listprod.php?categ=1&subcateg=7 I want it to dynamically do the following: www.example.com/listprod/cameras/slr Hello! First... I'm sorry about my english skills.. Seems that with my own language I don't get a correct or good answer So.. I have a site where visitors can put there favorite links to other sites and show them to others. My problem is multiple urls to same locations in sites-table. example: http://google.com http://google.com/ http://www.google.com http://www.google.com/ http://www.google.com/index.php (?) they all lead to same... is there any light and powerfull way to check these? I'm trying to use query with "like" but it only works if there is exactly same url. I use fopen to check that url really exicst.. table: Sites (basic information for link) -id -url -title +some meta tags if found -timestamp I'm not asking to do me this code. But if someone can tell me just what functions and others I'm looking for and what I need for this... My coal is to keep sites-table as clean as it can be. If visitor adds a url that is already in sites-table only thing that happens is updating timestamp. Thank you all for helping me! -Roosterr Say my URL is http://www.example.com/catalog.php?category=hats&prodID=53 and I use Mod-rewrite to make it http://www.example.com/catalog/hats/53/ Can I still use $_GET['category'] to get the parameters? If so, how? I would love to google my question, but I don't know how this is called.... I want to create URLs for each user of a site with this format: www.mysite.com/user1 Facebook does this, for example. In a static page I'd do it with a folder and index file for each user, but that's not practical if you have too many users. Could you explain how this is done or at least how it is called so I can find myself something to read? Thanks!!! Okay, i know there are lots of these questions out there and tons of ways to do this. I do have it working to replace URLs with <a href="URLs">URLs</a> but now i need some help detecting <a href=""></a> so the preg_replace will not double up the code and mess up the link. here is my code so far. Code: [Select] <?php echo 'COMMENTS<br /><br />'; while($rows = mysql_fetch_array($comres)){ list($comid, $menu_title, $post_id, $comdate, $comname, $comment) = $rows; $comment = nl2br($comment); $comment = preg_replace('/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/', '<a href="$0" target="_new">$0</a>', $comment); $comment = str_replace("´", "'", $comment); $comdate = date("g:ia - M j, Y",strtotime("$comdate")); echo 'User: '.$comname.'<font color="#B20303"> - '.$comdate.'</font><br />'; echo ' - '.$comment.'<br /><br />'; } ?> so with this code, if someone commented a link like this http://example.com it will turn it this <a href="http://example.com" target="_new">http://example.com</a> but now if someone knew some basic HTML coding, and they used this <a href="http://example.com">Example.com</a> it will look like this... <a href=<a href="http://example.com" target="_new">http://example.com</a>>Example.com</a> I would like to be able to have my meta data pick out the information of a page and insert it into the meta tags. I have a controller class which has the coding to get the data, which is this: controller.class.php Code: [Select] function get_title(){ $title=''; if (isset($this->_params['item']['meta_title']) && !empty($this->_params['item']['meta_title'])){ $title=$this->_params['item']['meta_title']; } $title=strip_tags($title); $title=str_replace('"', '\'', $title); $title=trim($title); if (strlen($title)>150){ $end_of_last_sentence=strpos($title, '.', 150)+1; if ($end_of_last_sentence<150){ $end_of_last_sentence=150; } $title=substr($title, 0, $end_of_last_sentence); } return $title; } function get_description(){ $description=''; if (isset($this->_params['item']['meta_description']) && !empty($this->_params['item']['meta_description'])){ $description=$this->_params['item']['meta_description']; } $description=strip_tags($description); $description=str_replace('"', '\'', $description); $description=trim($description); if (strlen($description)>150){ $end_of_last_sentence=strpos($description, '.', 150)+1; if ($end_of_last_sentence<150){ $end_of_last_sentence=150; } $description=substr($description, 0, $end_of_last_sentence); } return $description; } function get_keywords(){ $keyword=''; if (isset($this->_params['item']['meta_keyword']) && !empty($this->_params['item']['meta_keyword'])){ $keyword=$this->_params['item']['meta_keyword']; } $keyword=strip_tags($keyword); $keyword=str_replace('"', '\'', $keyword); $keyword=trim($keyword); if (strlen($keyword)>150){ $end_of_last_sentence=strpos($keyword, '.', 150)+1; if ($end_of_last_sentence<150){ $end_of_last_sentence=150; } $keyword=substr($keyword, 0, $end_of_last_sentence); } return $keyword; } Then I have a pages.controller which has the coding for the home page pages.controller.php Code: [Select] public function home(){ //instantiate a model $galleries_model = new galleries_model('galleries'); $galleries = $galleries_model -> get_all(); foreach($galleries as $gallery){ //how to loop through an image so that only the first //image is selected $sql = "SELECT image_path FROM gallery_images WHERE gallery_id = {$gallery['id']} ORDER BY order_by"; $image = $this->_model->get_one($sql); $gallery['image'] = $image; $this->_params['list'][] = $gallery; } $this->_params['item'] = $this->_model->get(array("pages.name = 'home'")); } Code: [Select] galleries.controller.php public function galleries(){ $galleries = $this->_model->get_all(); $this->_params['list'] = $galleries; } public function view($gallery_id){ $this->_params['item'] = $this->_model->get($gallery_id); $this->_params['item'] ; //die; } This is my default page where I want the meta tags to echo out the relevent information default.php Code: [Select] !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> <title><?php echo $this->get_title(); ?></title> <meta name="Description" content="<?php echo $this->get_description(); ?>" /> <meta name="Keywords" content="<?php echo $this->get_keywords(); ?>" /> <title>Welcome to the Framework</title> <?php $this->_page->add_javascript('/vendor/lightbox/js/jquery.lightbox-0.5.min.js'); $this->_page->add_stylesheet('/vendor/lightbox/css/jquery.lightbox-0.5.css'); echo $this->page('stylesheets'); echo $this->page('javascripts'); ?> </head> <body> <h1> Welcome to the My site </h1> <?php echo $this->page('view');?> </body> </html> In the pages.controller.php I managed to get it to work using $this->_params['item'] = $this->_model->get(array("pages.name = 'home'")); I want to be able to do the same thing on different pages but I can't get it to work. I hope I explained it clearly. Thank you Hi I have the following code, this code is suppose to get the data from the galleries table and the pages table. I think my problem is the sql statement but I'm not sure. Code: [Select] public function galleries(){ foreach($this->_params['list'] as $gallery){ $id = $gallery['id']; $name = $gallery['name']; $select = "SELECT * FROM pages, galleries WHERE pages.name = {$gallery['name']}"; $this->_params['item'] = $this->_model->get(array("pages.name = 'galleries.name'")); } the code Code: [Select] $this->_params['item'] = $this->_model->get(array("pages.name = 'galleries.name'")); works just fine with the home page and all the other pages. I have 2 galleries called gallery 1 and gallery 2, now my problem is that I need the sql to go through the galleries table look for the name and then look through the pages table and get the meta data from the same name. There is no foreign id because I only need it for the galleries and nothing else. Thank you |