Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
  1. #1
    Senior Member leprechaun13's Avatar
    Join Date
    May 2005
    Location
    Northampton
    Posts
    487
    Member #
    10058
    Wrote the following php script
    PHP Code:
    <?php
      
    include 'sqlconnect.php';
    $select "SELECT first_name, last_name FROM customers WHERE id=0";
    $result "mysqli_query($link,$select)" ;
    $row "mysqli_fetch_object($result)" ;
    $first $row ['first_name'] ;
    $last $row ['last_name'] ;
    echo 
    'First Name '.$first.' Last Name '.$last;
    "mysqli_close($link)"
    ?>
    When i open the file Instead of getting the output
    First Name Dave Last name Smith
    I get
    First Name m Last Name m
    i have checked my SQL table to check that evrything is how it should be and as far as i can see everything is fine
    Regards Phil,


  2.  

  3. #2
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Your column names may be correct, but check your tabel through a tool like phpMyAdmin to see what should be echoed out.

    Does this match?

    Edit: I use mysql_fetch_array..

    PHP Code:
    <?php
    include 'sqlconnect.php';
    $query "SELECT first, surname  FROM pages WHERE id=0";
    $result mysql_query($query) or die("Query failed: ".mysql_error());
    $numrows mysql_num_rows($result);
    mysql_close($link);
    while(
    $row mysql_fetch_array($result))
     {
        echo 
    $row['first'];
        echo 
    $row['second'];
     }
    ?>

  4. #3
    Senior Member leprechaun13's Avatar
    Join Date
    May 2005
    Location
    Northampton
    Posts
    487
    Member #
    10058
    Quote Originally Posted by bfsog
    Your column names may be correct, but check your tabel through a tool like phpMyAdmin to see what should be echoed out.

    Does this match?
    Yea the output sholud be first name dave last name burton
    can u tell me how you structured this table as this is n extension o fanothere thread you answered concerning the same script
    Regards Phil,


  5. #4
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    In the script I posted to you, it was a modified version (I only changed your column names to match one's on a table of mine).

  6. #5
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Why are you putting everything in quotes? Only strings should be in quotes.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  7. #6
    Senior Member leprechaun13's Avatar
    Join Date
    May 2005
    Location
    Northampton
    Posts
    487
    Member #
    10058
    Thanks how would i put this in a table
    Regards Phil,


  8. #7
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    PHP Code:
    <?php
    include("sqlconnect.php");
    $query "SELECT first, surname  FROM users";
    $result mysql_query($query) or die("Query failed: ".mysql_error());
    $numrows mysql_num_rows($result);
    if(
    $numrows >= 1) {
    echo 
    "<table width=\"400\">\n";
    while(
    $row mysql_fetch_array($result))
    {
        echo 
    "<tr>\n";
        echo 
    "<td width=\"200\">\n";
        echo 
    $row['username'];
        echo 
    "</td>\n";
        echo 
    "<td width=\"200\">\n";
        echo 
    $row['email'];
        echo 
    "</td>\n";
        echo 
    "</tr>\n";
    }
    echo 
    "</table>\n";
    }
    ?>
    Just make sure your table name matches as well as column names, and that should be you

  9. #8
    Senior Member leprechaun13's Avatar
    Join Date
    May 2005
    Location
    Northampton
    Posts
    487
    Member #
    10058
    Thanks bf youve been a great help
    Regards Phil,


  10. #9
    Senior Member leprechaun13's Avatar
    Join Date
    May 2005
    Location
    Northampton
    Posts
    487
    Member #
    10058
    Please can u help me again with this code
    PHP Code:
    <?php
    $query 
    "SELECT name, shopprice, streetprice, hialc, lowalc, examine, submitted FROM RuneS_Items";
    $result mysql_query($query) or die("Query failed: ".mysql_error());
    $numrows mysql_num_rows($result);
    if(
    $numrows >= 1) {
    echo 
    "<table>\n";
    while(
    $row mysql_fetch_array($result))
    {
    echo 
    "<TBODY>\n"
    echo 
    "<TR>\n"
    echo 
    "<TD>Item Name:$row['name']</TD>";
    echo 
    $row['name'];
    echo 
    "<TD> Shop Price:</TD>";
    echo 
    $row['shopprice']; 
    echo 
    "<TD>Low Alc: </TD>\n"
    echo 
    "<TD> High Alc:</TD></TR>\n;"
    echo 
    "<TR>\n"
    echo 
    "<TD>Examine Info:</TD>\n"
    echo 
    "<TD> </TD>\n"
    echo 
    "<TD> </TD>\n"
    echo 
    "<TD> </TD></TR>\n"
    echo 
    "<TR>\n"
    echo 
    "<TD>Submitted By:</TD>\n"
    echo 
    "<TD> </TD>\n"
    echo 
    "<TD> </TD>\n"
    echo 
    "<TD> </TD></TR></TBODY>\n";
    }
    echo 
    "</table>\n";
    }
    ?>
    </body>
    </html>]
    The informaton doesnt appear in the table. it isnt completely finished as i hvent added all of the rows
    Regards Phil,


  11. #10
    Senior Member leprechaun13's Avatar
    Join Date
    May 2005
    Location
    Northampton
    Posts
    487
    Member #
    10058
    oops sorry for the reapeated posts
    Regards Phil,



Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 03:46 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com