Confuse display data php

i want to display file that is in certain part. but it cant. i have try. please help meee

this is index.php

<?php
              $sql="SELECT * FROM tbl_uploads";
              $result_set=mysql_query($sql);
                while($row=mysql_fetch_array($result_set)){
                  if ($part == 'a'){
                       echo "<td><a href=\"uploads/<?php"; echo "".$row['file']."?>\" target=\"_blank\">View</a>";

                  }
                }

            ?>

i have database name tbl_uploads that have 5 table, thats id, file, type, size and part. so i want to display file that in part ‘a’ in database. pleaseee

Are you confusing Databases and Tables? Because you say the database is called tbl_uploads, but the query is calling a table with that name.
Does your script make a connection to the database first? I don’t see that in the code.

i make the connection in header. i want to display file that in part a. but cant

$part is never defined, so the condition will always be false

so what should i do?

Should the condition be:-

if ($row['part'] == 'a'){ }

…since part is a column in the table?

And if that is the case, why not put that in a where clause so you don’t have to loop through every record?

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.