Development Mysql unknown!

Discussion in 'Software' started by Bogomip, 22 Feb 2003.

  1. Bogomip

    Bogomip ... Yo Momma

    Joined:
    15 Jun 2002
    Posts:
    5,161
    Likes Received:
    39
    PHP:
        $number == "1";

        while($a_row = mysql_fetch_object($query)) {

            while($number < ($result + 1)) {

                if($a_row->number == $number) {

                        ?>

                        <tr>
                        <td width="4%"><?PHP print $a_row->number ?></td>
                        <td width="24%" bgcolor="#3366CC"><a href="<?PHP print $a_row->website ?>" target="NEW"><?PHP print $a_row->name ?></td>
                        <td width="5%" bgcolor="#6699cc"><?PHP print $a_row->age ?></td>
                        <td width="13%" bgcolor="#3366CC"><a href="mailto:<?PHP print $a_row->email ?>">Email <?PHP print $a_row->name ?></td>
                        <td width="20%" bgcolor="#6699cc"><?PHP print $a_row->location ?></td>
                        <td width="32%" bgcolor="#3366CC"><?PHP print $a_row->interests ?></td>
                        </tr>

                        <?PHP

                
    }

                
    $number $number 1;

            }


        }

        print 
    "</table>";
    I have been pouring over this for hours now and i cannot see why it wont list everything in my database. In the DB they are numbered starting from 1, but when i run this code, if it works atall it will only print the first entry. Any ideas why it isnt working ?

    thanks, Jaffer
     
  2. RTT

    RTT #parp

    Joined:
    12 Mar 2001
    Posts:
    14,120
    Likes Received:
    74
    that's to do with your $number variable being 1. It needs to be as big as the amount of rows in your table.
    mysql_num_rows($result) will return this for you from your query.

    try

    PHP:
    $number mysql_num_rows($query);
     
  3. Bogomip

    Bogomip ... Yo Momma

    Joined:
    15 Jun 2002
    Posts:
    5,161
    Likes Received:
    39
    but the number neds to start oin one, cause in my table, there is a number column, where all the users are numbered. I then compare the number to the row, then use that row. It needs to start at 1 and increase by 1 everytime.

    unless i have misunderstood what you are saying!
     
  4. RTT

    RTT #parp

    Joined:
    12 Mar 2001
    Posts:
    14,120
    Likes Received:
    74
    personally i'd go with -

    PHP:
    $a_row mysql_fetch_object($query);
    $number mysql_num_rows($query);
    $number1 "1";

    while (
    $number >= $number1) {

    echo (
    "
    <tr>
    <td width=\"4%\">
    $a_row->number</td>
    <td width=\"24%\" bgcolor=\"#3366CC\"><a href=\"
    $a_row->website\" target=\"NEW\">$a_row->name</td>
    <td width=\"5%\" bgcolor=\"#6699cc\">
    $a_row->age</td>
    <td width=\"13%\" bgcolor=\"#3366CC\"><a href=\"mailto:
    $a_row->email\">Email $a_row->name</td>
    <td width=\"20%\" bgcolor=\"#6699cc\">
    $a_row->location</td>
    <td width=\"32%\" bgcolor=\"#3366CC\">
    $a_row->interests</td>
    </tr>

    "
    );

    $number1++;

    }

     
  5. Bogomip

    Bogomip ... Yo Momma

    Joined:
    15 Jun 2002
    Posts:
    5,161
    Likes Received:
    39
    that didnt work either, its being vry funny so i just stole me some code form another one of my database things i made. I have no idea to this time what the heck was going on :)

    thanks for your help though :)
     
  6. RTT

    RTT #parp

    Joined:
    12 Mar 2001
    Posts:
    14,120
    Likes Received:
    74
    I've never used a function to call stuff from a db, was kinda guess work :worried:

    I usually do it the long way and use

    $row = mysql_query($query)

    $something = $row['something'];

    etc
     

Share This Page