Results 1 to 4 of 4

Thread: Need Help in PHP

  1. #1
    Join Date
    Dec 2008

    Post Need Help in PHP

    I run a PHP site ..

    Say i create a database that has one column say NAMES: its values are JHON etc. Now i need a code that can be put on my website and when a user visits the page and if the page has got JHON on it. It converts it into a hyperlink?

    Basically some code that calls my database that has NAMES and Fetches all the Name that it has and converts it into a hyperlink.

  2. #2
    Join Date
    Apr 2007
    There are a lot of PHP MySQL tutorials on the net. What you want to do is about as basic as it gets.

    First you should know a database has tables (which have names) and tables have columns (which have names). Databases don't have columns.

    You will of course need to change the data in this to match your database and table names.

    PHP Code:
    <? php

    the imaginary table 'tablename' has this data
    name    url
    bob    bobspage.html    
    john    johnsbetterpage.html

    $query='SELECT * FROM tablename';

    '<a href="'.$row['url'].'">'.$row['name'].'</a><br />';


  3. #3
    Join Date
    Nov 2008
    A couple of typos in the above example, this is what SyCo meant:

    PHP Code:

    ='SELECT * FROM tablename';

    '<a href="'.$row['url'].'">'.$row['name'].'</a><br />';

    Also I think what you are asking is how to scan a page and replace any instances of name with the link? If so you are really thinking about it the wrong way round. You need to design your page so that the correctly hyperlinked name is there in the first place. Using the technique SyCo posted is the correct way to approach this problem.
    Last edited by Mindzai; 01-03-2009 at 05:00 AM.

  4. #4
    Join Date
    Apr 2007
    Yea I try not to over abbreviate when posting here but I'm all $q $r $k $v as that means plently to me. I try not to confuse here but sometimes they do slip by. Thanks for the corrections. I try to remind people, all code posted is to be considered is 'pseudo code'

    err I mean, congratulations you spotted the deliberate error of the day.

    I doubt this user even read this, he never did reply!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles