Display Multiple Rows From MYSQL Database with PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ameshkin

    #1

    Display Multiple Rows From MYSQL Database with PHP

    I know this is probably not too hard to do, but how do I display
    multiple rows of a mysql query/recordset. Im having trouble doing
    this. I don't just want to display them, but I want to make sure ONE
    field in each row gets a variable.

    The table name is RecentUploads, the field I want to pull is XML

    This is probably something simple that is more experienced, but I've
    only been doing this for a couple of months. Any help would be
    appreicated.

    Thank You



  • Michael Austin

    #2
    Re: Display Multiple Rows From MYSQL Database with PHP

    ameshkin wrote:
    [color=blue]
    > I know this is probably not too hard to do, but how do I display
    > multiple rows of a mysql query/recordset. Im having trouble doing
    > this. I don't just want to display them, but I want to make sure ONE
    > field in each row gets a variable.
    >
    > The table name is RecentUploads, the field I want to pull is XML
    >
    > This is probably something simple that is more experienced, but I've
    > only been doing this for a couple of months. Any help would be
    > appreicated.
    >
    > Thank You
    >
    > http://www.mytuneslive.com
    >[/color]

    There are some things the mysql database server can do for you ...

    if c = space or c is empty or c p xyz then change it to zero otherwise leave it
    as it is (or change it to something else....)

    select a, b, case when c is null or c = ' ' or c = 'xyz' then '0' else c end, d,
    e, f from table where....

    Then simply display the results.

    or

    $link=mysql_con nect($HOST,$USR ,$PWD,$DB);
    if( $link ) {
    mysql_select_db ( $DB, $link );
    if( $sql ) {
    $sql = ereg_replace( ";$", "", $sql );
    $sql = ereg_replace( "\\\\", "", $sql );
    $result = mysql_query( $sql, $link );
    if( $result ) {
    echo( "<p>Results : for '$sql;'.</p>\n" );
    if( $num = mysql_num_rows( $result ) ) {
    echo( "<pre>\n" );
    while( $array = mysql_fetch_row ( $result ) ) {
    while( list($key, $val) = each( $array ) ) {
    -->>> here check to see if the val for key = whatever and change it...
    echo "$val | ";
    } # end while
    echo "<br />\n";
    } # end while
    echo( "</pre>" );
    } elseif( $af = mysql_affected_ rows( $link ) ) {
    echo( "<p>$af rows affected.</p>\n" );
    } else {
    echo( "<p>Command completed.</p>\n" );
    } # end if
    } else {
    echo( "<p>Bad query: '$sql;'.</p>" );
    echo( mysql_errno() . ": " .
    mysql_error() . "<br />" );
    } # end if
    } else {
    echo( "<p>Connect ed to '$DB'.</p>" );
    } # end if
    } else {
    echo( "<p>Bad connection.</p>" );
    echo( mysql_errno() . ": " .
    mysql_error() . "<br />" );
    } # end if
    ?>


    --
    Michael Austin.

    Comment

    • ameshkin

      #3
      Re: Display Multiple Rows From MYSQL Database with PHP

      Michael,
      That was a little too complicated. If i were to show you my code, do
      you think you could fix it?

      Comment

      Working...