below is what i use at the moment to show fields from my database i was trying to get login to work but could not so what i did when peeps register i put a field in called active and made that field =1 so what i want to do is when peeps click browse it just shows the fields below if active = 0 but if active = 1 then it will show extra fields hope you understand thanks Doug $result = mysql_query("SELECT * FROM exchange"); echo "<table border='1'> <tr> <p align='center' class='bodytext'> <th>parkname</th> <p align='center' class='bodytext'> <th>parklocation</th> <p align='center' class='bodytext'> <th>caravandetails </tr>";while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['parkname'] . "</td>"; echo "<td>" . $row['parklocation'] . "</td>"; echo "<td>" . $row['caravandetails'] . "</td>"; echo "</tr>"; } echo "</table>";mysql_close($con); ?> </p> </body> PHP:
while($row = mysql_fetch_array($result)) { $active=$row['active']; } if($active==0) { show normal fields } else { show extra fields } i hope you will understand this pseudocode
is this how you mean if i have done it right it didnt work $result = mysql_query("SELECT * FROM exchange"); echo "<table border='1'> <tr> <p align='center' class='bodytext'> <th>parkname</th> <p align='center' class='bodytext'> <th>parklocation</th> <p align='center' class='bodytext'> <th>caravandetails</th> <p align='center' class= 'bodytext'> <th>email </tr>";while($row = mysql_fetch_array($result)) { $active=$row['active']; } if($active==0) { echo "<tr>"; echo "<td>" . $row['parkname'] . "</td>"; echo "<td>" . $row['parklocation'] . "</td>"; echo "<td>" . $row['caravandetails'] . "</td>"; echo "</tr>"; } else { echo "<tr>"; echo "<td>" . $row['parkname'] . "</td>"; echo "<td>" . $row['parklocation'] . "</td>"; echo "<td>" . $row['caravandetails'] . "</td>"; echo "<td>" . $row['email'] . "</td>"; echo "</tr>"; } echo "</table>";mysql_close($con); ?> </p> </body> </html> PHP:
ok, lines if($active==0) { echo "<tr>"; echo "<td>" . $row['parkname'] . "</td>"; echo "<td>" . $row['parklocation'] . "</td>"; echo "<td>" . $row['caravandetails'] . "</td>"; echo "</tr>"; } else { echo "<tr>"; echo "<td>" . $row['parkname'] . "</td>"; echo "<td>" . $row['parklocation'] . "</td>"; echo "<td>" . $row['caravandetails'] . "</td>"; echo "<td>" . $row['email'] . "</td>"; echo "</tr>"; } PHP: must be in while loop after $active = .... like this: $result = mysql_query("SELECT * FROM exchange"); echo "<table border='1'> <tr> <p align='center' class='bodytext'> <th>parkname</th> <p align='center' class='bodytext'> <th>parklocation</th> <p align='center' class='bodytext'> <th>caravandetails</th> <p align='center' class= 'bodytext'> <th>email </tr>";while($row = mysql_fetch_array($result)) { if($row['active']==0) { echo "<tr>"; echo "<td>" . $row['parkname'] . "</td>"; echo "<td>" . $row['parklocation'] . "</td>"; echo "<td>" . $row['caravandetails'] . "</td>"; echo "</tr>"; } else { echo "<tr>"; echo "<td>" . $row['parkname'] . "</td>"; echo "<td>" . $row['parklocation'] . "</td>"; echo "<td>" . $row['caravandetails'] . "</td>"; echo "<td>" . $row['email'] . "</td>"; echo "</tr>"; } } echo "</table>";mysql_close($con); ?> </p> </body> </html> PHP: on that if, I removed $active, there is no need for extra variables