+ Reply to Thread
Results 1 to 7 of 7

Thread: Individulise hyperlinks from MySQL
      
   

  1. #1
    Rob (SA)'s Avatar
    Rob (SA) is offline Lieutenant Colonel
    Join Date
    Nov 2006
    Location
    Centurion, South Africa
    Posts
    580

    Question Individulise hyperlinks from MySQL

    Hi Folks,

    I have managed to change all the names in a table to hyperlinks.

    These links need to be individualised that if I pick the name it goes straight to that members page.

    I would appreciate any ideas that I can develop the individual pages and a method to test that the links to each member works.

    Each members info comes from a datbase in MYSQL and so data should be unique.

    I look forward to any replies

  2. #2
    Rob (SA)'s Avatar
    Rob (SA) is offline Lieutenant Colonel
    Join Date
    Nov 2006
    Location
    Centurion, South Africa
    Posts
    580

    Question Re: Individulise hyperlinks from MySQL

    Hi Folks,

    Maybe said it incorrectly.

    The page as links is done fine at www.gnjgf.co.za/watflip.php

    However when I pick on a name it shows that I hav picked all the names and that is not what I am looking for.

    I would like to pick an individuals name which will then direct me to the correct page

  3. #3
    Rob (SA)'s Avatar
    Rob (SA) is offline Lieutenant Colonel
    Join Date
    Nov 2006
    Location
    Centurion, South Africa
    Posts
    580

    Question Re: Individulise hyperlinks from MySQL

    Hi Folks,

    I have inserted the bit of code that might be the cause of my problem:

    echo '<a href=<option value="'.$row['surname'].', '.$row['name'].'">'.$row['surname'].', '.$row['name'].'</a></option>';

    I look forward to your replies

  4. #4
    Watdaflip's Avatar
    Watdaflip is offline Major General
    Join Date
    Sep 2005
    Location
    Cincinnati, Ohio
    Posts
    2,119

    Default Re: Individulise hyperlinks from MySQL

    Your inserting a html tag inside an attribute for another tag.

    The option tag is only used inbetween <select></select> tags.

    What you need to do is use url variables and php's $_GET superglobal to retrieve the variables.

    Your url will look like

    href="http://yoursite.com/file.php?surname='.$row['surname'].'&name='.$row['name'].'"

    However, you will probably want to use just use the numeric id for that row. Not only is it a cleaner url, it will produce a more efficient query when you are actually loading the row. It is also easier security wise as well.

    On the php file to list the data for the specific row, just retrieve the data using $_GET['surname'], or $_GET['name'].

    Lastly, if you do choose to use the id as the only passed variable, you can just use a simple function to check if it is numeric before using it in a query

    if(is_numeric($_GET['id'])) {
    // execute query
    } else { die("Hacking attempt"); }

    Assuming that your code is logically correct, there should never be a time when anything other then a number is in the url by anything generated by the script. If there is then someone manually added it to the url.

    Oh and lastly, don't take an offense by this, but you should probably take some time and go over more html/php tutorials. Without having the basic down first your going to cause alot of headaches in the long run.

    Register/Login Script
    Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

  5. #5
    Rob (SA)'s Avatar
    Rob (SA) is offline Lieutenant Colonel
    Join Date
    Nov 2006
    Location
    Centurion, South Africa
    Posts
    580

    Question Re: Individulise hyperlinks from MySQL

    Hi,

    Thanks for the reply.

    What I am understanding from this is that:

    The href. . . . should happen in another section of the html code and not in th eplace I have currently presented it?

    The variable as presented at www.gnjgf.co.za/watflip.php presents correctly from MySql however and the hyperlink shows however when clicked all highlight as if all are picked.

    What needs to happen though is that each name picked should be redirected to a new page and specifically a page with their name /id that their stats may be veiwed - logins will be the norm for those pages.

    Last comment - I am always happy to take advice. If I understand you are asking I do a bit more reading on php / html. No offense taken but I search the internet continously to find resolution to my challenges and as a memebr here welcome the support guys like yourselves and Naval offer.

    If I do not understand correctly please advise

  6. #6
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,061

    Default Re: Individulise hyperlinks from MySQL

    There is no issue asking for help. What Watdaflip is actually saying (i believe) , is that you are trying to apply scripts that you search on the internet or we supply, but you actually haven't got the entire vision of how you can perform certain tasks. So you do copy a script and make it work by trial and error, but you don't yet have the necessary html / php knowledge to the extend required to build a complete application.

    Building an application requires
    1. Setting the goals, as detailed as possible.
    2. Schedule future extensions / upgrades, as least as far as possible.
    3. Creating the logical diagram
    4. Coding

    As you understand, you must know a bit more of HTML and PHP (and also MySQL, to correctly build the queries with PHP). Otherwise you will always have issues with your work trying to debug errors.

    This is why Watdaflip (And I) suggest that you first get some HTML / PHP theoretical knowledge by reviewing some of the tutorials available on the net. And, i myself, repeat, no offense with this. We have also been through the same steps, and we have had to learn at least the basics before attempting to code an application.

    Now, regarding your code: this is what you have in your table rows:


    <td bgcolor=#C6DEFF><font style="font-size:10px" color="#00008B" face="Arial"><a href=<option value="ALVES, SERGIO">ALVES, SERGIO</a></option></td>

    Which is coming out, i believe, from a piece of php code like:

    loop start.......
    echo'
    ............
    <td bgcolor=#C6DEFF><font style="font-size:10px" color="#00008B" face="Arial"><a href=<option value="''.$lastname.'", ".$firstname ">'.$lastname.", ".$firstname.'</a></option></td>
    ............rest of columns
    closing loop tag.....

    where $firstname and $lastname are retrieved from the DB

    The <a href=<option value="''.$lastname.'" ".$firstname ">'.$lastname." ".$firstname.'</a></option> is wrong.

    It should be something like:

    <td bgcolor=#C6DEFF><font style="font-size:10px" color="#00008B" face="Arial><href="members_page.php?Record_nr='.$R ecord_nr.'">'.$lastname.'" ".$firstname.'</a><font></td>

    This will create, for each member, a link like members_page.php?Record_nr=31 . In the members page (members_page.php) you should have first of all a line like

    $Record_nr = intval($_GET['Record_nr']);

    So you capture the member's ID (the Record_nr since you use ABVFP to store the members info in the table):

    Based on this Record_nr you then build your query to retrieve the member's info from the table and display it in your member's page:

    $query = "SELECT * from tablename WHERE Record_nr= '$Record_nr'";
    .....etc

    The <option tag that you have used has no place in there , it is only used within the <select> ...... </select> tags (a selection list) to create the list options.
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  7. #7
    Rob (SA)'s Avatar
    Rob (SA) is offline Lieutenant Colonel
    Join Date
    Nov 2006
    Location
    Centurion, South Africa
    Posts
    580

    Thumbs up Re: Individulise hyperlinks from MySQL

    Hi George,

    Thanks very much for the detailed expliantion, i appreciate it and understand more clearly your stand points.

    I am in the process of this exercise trying to learn th evarious aspects of html /php an dyes it has its own challenges.

    I will work harder on the logical diagram as I believe this does help and read further on html / php coding. The syntax of thelanguage is a bit of a challenge but I am sure this will evolve as I learn more.

    Thanks for the advice on the code.

    I only tried to place the tags <A> href in the esisting code na dthis provided the effect I am now seeing. So I got excited to see that I could get that part to work only to the frustration of realising it was not quite correct.

    I will dable a bit further with your presentation below and hope that I can get the desired result.

    I really appreciate all your assitance

Thread Information

Users Browsing this Thread

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

     

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49