Can't get all the results to show in my form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phopman
    New Member
    • Aug 2007
    • 26

    Can't get all the results to show in my form

    I have a beautiful, dynamic and very attractive front page:

    [PHP]<?php
    error_reporting (E_ALL);
    ini_set('displa y_errors', '1');
    include '../../db.inc';


    $id = intval( mysql_real_esca pe_string( $_GET['id'] ));
    //echo "id = $id";
    // Connect to server and select database.


    $sql="SELECT name,link FROM $tbl_name where contentid = '$id'";
    $result=mysql_q uery($sql);

    ?>
    <table width="180" border="0" cellspacing="1" cellpadding="0" >
    <tr>
    <td>
    <table width="170" border="0" cellspacing="0" cellpadding="1" >
    <tr>

    </tr>

    <tr>

    </tr>
    <?php
    while($rows=mys ql_fetch_array( $result)){
    ?>
    <tr>
    <td><? echo $rows['name']; ?></td>
    <td><? echo $rows['link']; ?></td>
    </tr>
    <?php
    }
    ?>
    </table>
    </td>
    </tr>
    </table>
    <td align="center"> <a href="update_do c.php?id=<? echo $id;?>">update</a></td>
    <td align="center"> <a href="delete_do c.php?id=<? echo $id;?>">delete</a></td>
    <td align="center"> <a href="insert_do c.php?id=<? echo $id;?>">insert</a></td>
    <?php
    mysql_close();
    ?>[/PHP]

    And my update_doc.php is also very beautiful, attractive.
    [PHP]<?php
    error_reporting (E_ALL);
    ini_set('displa y_errors', '1');
    include '../../db.inc';

    $tbl_name="jos_ documentation"; // Table name
    // Connect to server and select database.
    //mysql_connect(" $host", "$username" , "$password" )or die("cannot connect");
    //mysql_select_db ("$db_name") or die("cannot select DB");

    // get value of id that sent from address bar
    $id=$_GET['id'];

    // Retrieve data from database
    $sql="SELECT name,link FROM $tbl_name WHERE contentid='$id' ";
    $result=mysql_q uery($sql);
    $rows=mysql_fet ch_array($resul t);

    ?>

    <table width="400" border="0" cellspacing="1" cellpadding="0" >
    <tr>
    <form name="form1" method="get" action="update_ ac.php">
    <td>
    <table width="100%" border="0" cellspacing="1" cellpadding="0" >
    <tr>
    <td>&nbsp;</td>
    <td colspan="3"><st rong>Update Main Issues</strong> </td>
    </tr>
    <tr>
    <td align="center"> &nbsp;</td>
    </tr>
    <tr>
    <td align="center"> &nbsp;</td>
    <td align="center"> <strong>Name</strong></td>
    </tr>
    <tr>
    <td>&nbsp;</td>

    <td align="center"> <input name="name" type="text" value="<? echo"$rows[name]"; ?>" size="30" /></td>
    <td align="center"> <input name="name" type="text" value="<? echo"$rows[link]"; ?>" size="30" /></td>


    </label></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td><input name="id" type="hidden" id="id" value="<? echo $rows['contentid']; ?>"></td>
    <td align="center"> <input type="submit" name="Submit" value="Submit"> </td>
    <td>&nbsp;</td>
    </tr>
    </table>
    </td>
    </form>
    </tr>
    </table>

    <?

    // close connection
    mysql_close();

    ?>[/PHP]

    Problem is that it will only give me the first set of data, name link.


    And I'm guessing it should be a petty thing that I have either a) not done or b) done wrong.

    Can anyone of you point me in the right direction?

    when I do an:

    [PHP]SELECT name,link from table where contentid='13'[/PHP] I get two lines of results, instead of only one.


    Thank's in advance for all help!

    Phopman
    Last edited by phopman; Sep 3 '07, 09:46 AM. Reason: Removing some connetion info.
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    Excuse my late reply. Seems your thread managed to slip by unnoticed.

    If you look at your first page. Notice how you use a while() loop to loop through each and every one of the rows returned by the database.

    The second page does not. It simply reads a single row and displays it, ignoring the rest of the rows completely.

    If you simply add the same loop to your second page, your problem will be fixed.

    Comment

    • phopman
      New Member
      • Aug 2007
      • 26

      #3
      No problem. Solved it partly. Generated the code necessary in Dreamweaver, so now I have it up and running. Except that I can't make it print out every row there is... Maybe I will have to check the while inside the DW code again?

      THanks for the help anyway.!

      Comment

      Working...