Results 1 to 6 of 6

Thread: Help With PHP Code

  1. #1
    Senior Member
    Join Date
    Sep 2003
    Location
    London
    Posts
    255
    Thanks
    1
    Thanked
    0 times in 0 posts

    Help With PHP Code

    I am new to PHP and have being trying to get this bit of code to work. The problem seems to be the $ID value if I chaneg it to a 1 or 2 it displays the corresponding record. It should display all the records not sure why. Can you assist?

    <html>
    <h2>List Records</h2>
    <a href='add.php'>Add Record</a><br>
    </html>
    <?php
    include("connect.php");
    $sql = "SELECT * FROM daniels_addresses WHERE ID='$ID'";
    $query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error());
    while($result = mysql_fetch_array($query)) {
    $FirstName = stripslashes($result["FirstName"]);
    $LastName = stripslashes($result["LastName"]);
    $Address = stripslashes($result["Address"]);
    $Email = stripslashes($result["Email"]);
    $ID = $result["ID"];

    echo "$FirstName $LastName [<a href='edit.php?id=$ID'>Edit</a> | <a href='delete.php?id=$ID'>Delete</a>]<br>";

    }

    ?>
    Specs:

    Q6600 G0, Thermalright Ultra 120, ABIT IP35 PRO, 4GB Corsair DDR2, Trusty old Tagan 480u, BFG 8800 GTS 512, Samsung F1 750 GB.

    "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."

    Albert Einstein

  2. #2
    Funking Prink! Raz316's Avatar
    Join Date
    Jul 2003
    Location
    Deal, Kent, UK
    Posts
    2,978
    Thanks
    130
    Thanked
    62 times in 52 posts
    $sql = "SELECT * FROM daniels_addresses WHERE ID='$ID'";

    that is telling it to show only the relevant ID, if you get rid of the WHERE part, it should show them all.

  3. #3
    Senior Member
    Join Date
    Sep 2003
    Location
    London
    Posts
    255
    Thanks
    1
    Thanked
    0 times in 0 posts
    Sorry, How would I write the line?

  4. #4
    Funking Prink! Raz316's Avatar
    Join Date
    Jul 2003
    Location
    Deal, Kent, UK
    Posts
    2,978
    Thanks
    130
    Thanked
    62 times in 52 posts
    $sql = "SELECT * FROM daniels_addresses";

  5. #5
    Senior Member
    Join Date
    Sep 2003
    Location
    London
    Posts
    255
    Thanks
    1
    Thanked
    0 times in 0 posts
    Cheers mate that works now. Back to the books for me!!!
    Specs:

    Q6600 G0, Thermalright Ultra 120, ABIT IP35 PRO, 4GB Corsair DDR2, Trusty old Tagan 480u, BFG 8800 GTS 512, Samsung F1 750 GB.

    "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."

    Albert Einstein

  6. #6
    Funking Prink! Raz316's Avatar
    Join Date
    Jul 2003
    Location
    Deal, Kent, UK
    Posts
    2,978
    Thanks
    130
    Thanked
    62 times in 52 posts
    glad to hear it, good luck

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. PHP Tutorials
    By gss03 in forum Software
    Replies: 4
    Last Post: 09-05-2004, 12:09 PM
  2. Creating databases using PHP?
    By Nemeliza in forum Software
    Replies: 10
    Last Post: 22-11-2003, 10:45 PM
  3. PHP and MySQL
    By Kezzer in forum Software
    Replies: 4
    Last Post: 28-10-2003, 02:59 PM
  4. php problem...
    By Joel in forum Software
    Replies: 2
    Last Post: 12-10-2003, 11:39 PM
  5. Syntax Highlighting PHP Editor
    By Jonny M in forum Software
    Replies: 7
    Last Post: 11-09-2003, 10:43 AM

Posting Permissions

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