Re: looping through a database

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



i am not sure what u want to do, for this case you need to tell us
about your database table
structure. i quess you have table like this.. assume the table name is
table1 and there are ten
column in it file1..file10 respectively

|table1         |
|member_id |
|file1            |
|file2            |
|file3            |
|   :              |
|file10          |

while($row =  mysql_fecth_array($sql_result))
{
      echo display_file($row['file1']);
      echo display_file($row['file2']);
      :
      echo display_file($row['file10']);

}

function display_file($filename)
{
       if file not exist or null etc
              return           add file here link
      else
              return          display file, delete file

}

this is the idea. of course maybe not what you want, unless you can tell us what
really you want to do or what you got..

On 6/17/08, Wolf <LoneWolf@xxxxxxxxx> wrote:
> Richard Kurth wrote:
>> Wolf wrote:
>>> Richard Kurth wrote:
>>>> Could you please give me an idea where to start looking
>>>>
>>>> while($row=mysql_fetch_array($sql_result)){
>>>>
>>>> if ($row["number"]==1) {
>>>> <tr>
>>>> <td> File 1</td>
>>>> <td>This is the file</td>
>>>> <td>Delete</td>
>>>> </tr>
>>>> }else{
>>>> <tr>
>>>> <td>File1</td>
>>>> <td></td>
>>>> <td>Add</td>
>>>> </tr>
>>>> }
>>>>
>>>> }
>>>
>>>
>>> What is the query being executed?
> <!-- SNIP -->
>
>>>
>> This is the query being executed
>> $sql = "SELECT * FROM table WHERE members_id =" . $_SESSION["members_id"];
>> $sql_result = mysql_query($sql) or die(mysql_error());
>>
> That still pretty much tells me nothing.
>
> Does your table named table exist?
> Does your script connect or error?
> What DOES output to your screen?
> Does the schema for your table contain numbers?
>
> What happens when you use $row['number']?
>
> Or are you just hoping for someone to write your code?
>
> As written, your code will fail due to having PHP interspersed with HTML
> code.  As such, you either need to echo or exit out of the PHP areas and
> then continue.
>
> Wolf
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux