Results 1 to 12 of 12

Thread: I try to make a list in html with php from a myqsl database. please help

  1. #1
    Join Date
    Apr 2005
    Posts
    9

    I try to make a list in html with php from a myqsl database. please help

    the source is like this:

    <html>
    <head>
    <title>title</title>
    </head>

    <body>
    <h1>title</h1>
    <form action="file.php" method="post">
    old value:<br />
    <select name="old_value">
    <?php
    @$bd=mysql_pconnect('localhost', 'user', 'password');
    if (!$bd)
    { die('no connection: ' . mysql_error());
    }
    $select_bd = mysql_select_db('database', $bd);
    if (!$select_bd)
    { die ('cannnot open database : ' . mysql_error());
    }
    $rezultat=mysql_query("select field from table order by field ",$bd);
    $no_raws=mysql_num_rows($result);
    for( $i=0;$i<$numar_linii;$i++)
    { $rand=mysql_fetch_array($result);
    echo '<option value="';
    echo stripslashes($rand['field ']);
    echo '">';
    echo stripslashes($rand['field ']);
    echo '</option>';
    }
    ?>
    </select>
    <br />
    new value:<br />
    <input name="new_value" type="text" value="" maxlength="20">
    <br />
    <input type="submit" value="Change">
    </form>
    </body>
    </html>

    when i check it in my IDE it works, but it's not working in my browser.
    i need immediate help

  2. #2
    Join Date
    Feb 2003
    Posts
    1,048
    What does happen when you view it in your browser? Do you see a blank page, get an error, see the source code or what?

    Help will be more immediate if you give us all of the details.

  3. #3
    Join Date
    Apr 2005
    Posts
    9

    re

    in my browser the list is empty. the form is created, but has no entries init.

  4. #4
    Join Date
    Apr 2005
    Location
    florida
    Posts
    89
    I think this is a bi-variable problem:

    the query result is stored in "$rezultat"....

    $rezultat=mysql_query("select field from table order by field ",$bd);


    And you used "$result" for the rest of the script...

    $no_raws=mysql_num_rows($result);


    Solution: use exclusively "$rezultat" or "$result" for all the script..

    --------------------

    So, to have a quick solution, just replace this the following string:

    $rezultat=mysql_query("select field from table order by field ",$bd);

    by :
    $result=mysql_query("select field from table order by field ",$bd);

    And... Go and refresh your Page and give a smile...





    Good luck...

  5. #5
    Join Date
    Apr 2005
    Posts
    9
    silly me
    i use the same variable. because english is not my native language and i use romanian words for variables i tried tochange them into english, but apparently not all of them.

  6. #6
    Join Date
    Apr 2005
    Location
    florida
    Posts
    89
    So,
    does it work when you replace "rezultat" by "result"?

  7. #7
    Join Date
    Apr 2005
    Posts
    9
    yes but only in IDE. in browser it shows anempty list

  8. #8
    Join Date
    Apr 2005
    Location
    florida
    Posts
    89
    May I see the real source?
    (don't send the real password...)

  9. #9
    Join Date
    Apr 2005
    Posts
    9
    ok, it doesn't matter anyway, i tried tochange non english words inorder to make it easier, but if you want so...
    it's a ***.htm file.


    <html>
    <head>
    <title>Modificare disciplina</title>
    </head>

    <body>
    <h1>Ati ales modificarea numelui unei discipline</h1>
    <form action="modificadisciplina.php" method="post">
    Alegeti numele disciplinei ce urmeaza a fi modificata:<br />
    <select name="valoare_veche">
    <?php
    @$bd=mysql_pconnect('localhost', 'secretar', 'secret');
    if (!$bd)
    { die('Nu se poate conecta: ' . mysql_error());
    }
    $selectare_bd = mysql_select_db('scoala', $bd);
    if (!$selectare_bd)
    { die ('nu se poate deschide baza de date scoala : ' . mysql_error());
    }
    $rezultat=mysql_query("select dnume from discipline order by dnume",$bd);
    $numar_linii=mysql_num_rows($rezultat);
    for( $i=0;$i<$numar_linii;$i++)
    { $rand=mysql_fetch_array($rezultat);
    echo '<option value="';
    echo stripslashes($rand['dnume']);
    echo '">';
    echo stripslashes($rand['dnume']);
    echo '</option>';
    }
    ?>
    </select>
    <br />
    Introduceti noul nume al disciplinei:<br />
    <input name="valoare_noua" type="text" value="" maxlength="20">
    <br />
    <input type="submit" value="Schimba">
    </form>
    </body>
    </html>

  10. #10
    Join Date
    Apr 2005
    Posts
    9
    apparently i solved the problem.
    the sourcemust be saved as php file.
    if anyone have an idea of using htm files instead i'm still interested

  11. #11
    Join Date
    Feb 2003
    Posts
    1,048
    It is possible to use .htm files but in order to do so, you first have to make certain configuration changes within the PHP engine itself. It's best to just use the php extension.

  12. #12
    Join Date
    Apr 2005
    Posts
    9

    Smile

    thanks

Posting Permissions

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