hey guys so basically what i want to do is populate a table with details from a database. That is part of the problem. When i write the php coding to do that the other elements on the webpage sort of disappear. Ill attach some screenshots to make it clearer.

without the php coding:
81ed4627bf49a59e5e215b52917d0eeb

with coding:

also the database is currently empty coz im just testing the coding and i was wondering since the database is empty is there a way so that "no database selected" is not shown when the table is empty?

coding:

<div style="width:600px; margin-left:200px;float:left;">
    <table id='currevents' border='2' rules='all' cellspacing='5px' cellpadding='5px'>
        <thead>
            <tr align='left'>
                <td width='50px'>Event</td>
                <td width='50px'>Type</td>
                <td width='50px'>Date</td>
                <td width='50px'>Time</td>
                <td width='50px'>Venue</td>
            </tr>
        </thead>
        <tbody>
<?php

            $sql="SELECT * FROM event";
            $result=mysql_query($sql) or die(mysql_error());

            while($row=mysql_fetch_array($result)){
            $name=$row['event_name'];
            $type=$row['event_type'];
            $date=$row['event_date'];
            $time=$row['event_time'];
            $venue=$row['event_venue'];

            echo "<tr>
                <td>.$name.</td><td>.$type.</td><td>.$date.</td><td>.$time.</td><td>.$venue.</td>
            </tr>";

            }   
?>
        </tbody>
    </table>
</div>

Recommended Answers

All 3 Replies

I think the 'no database selected' is caused by your code. Do you have a mysql_select_db() somewhere?

Share the PHP script that you are using to connect to the database.

sorry guys i figured it out. It has to do with this js plugin im using, datatables.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.