Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplay results in multiple html tables
    primarykey
    data
    text
    <p>I have been making a volunteer sign up sheet for our hockey club. I display the results in a table using a while loop.</p> <p>Everything works good, but I am now wanting to make the output a little more user friendly. I order the query by the date and display it in a single table. What I would like to do is display a new table for each different date. The heading of that table would be the date and the rows would have all events for that date ordered by time. I think this would make it easier for people to find events on a specific date.</p> <p>Here is how my table is set up: id, date, time, game, name1, name2, name3, name4, name5</p> <p>Here is the query on my main page:</p> <pre><code>&lt;?php //displays the table $result = mysql_query("SELECT * FROM namestable ORDER BY date, time ASC"); displayTable($result); ?&gt; </code></pre> <p>This is my function:</p> <pre><code>&lt;?php function displayTable($result){ echo " &lt;table border='1'&gt; &lt;tr class='top'&gt; &lt;th class='date'&gt;Date&lt;/th&gt; &lt;th class='time'&gt;Time&lt;/th&gt; &lt;th class='game'&gt;Game&lt;/th&gt; &lt;th class='name'&gt;Name&lt;/th&gt; &lt;th class='name'&gt;Name&lt;/th&gt; &lt;th class='name'&gt;Name&lt;/th&gt; &lt;th class='name'&gt;Name&lt;/th&gt; &lt;th class='name'&gt;Name&lt;/th&gt; &lt;th class='sign'&gt;Sign Up&lt;/th&gt; &lt;/tr&gt;"; while($row = mysql_fetch_array($result)) { //change the date format here $fdate = date('M jS, Y l', strtotime($row['date'])); echo "&lt;tr&gt;"; echo "&lt;td class='date'&gt;" . $fdate . "&lt;/td&gt;"; echo "&lt;td class='time'&gt;" . $row['time'] . "&lt;/td&gt;"; echo "&lt;td class='game'&gt;" . $row['game'] . "&lt;/td&gt;"; echo "&lt;td class='nameA'&gt;" . $row['name1'] . "&lt;/td&gt;"; echo "&lt;td class='nameB'&gt;" . $row['name2'] . "&lt;/td&gt;"; echo "&lt;td class='nameA'&gt;" . $row['name3'] . "&lt;/td&gt;"; echo "&lt;td class='nameB'&gt;" . $row['name4'] . "&lt;/td&gt;"; echo "&lt;td class='nameA'&gt;" . $row['name5'] . "&lt;/td&gt;"; $id = $row['id']; echo "&lt;td class='sign'&gt;" . "&lt;form name='input' action='process.php' method='POST'&gt; &lt;input type='text' name='name' maxlength='25' value='Enter Name' onfocus=\"if(this.value=='Enter Name') this.value='';\"/&gt; &lt;input type='hidden' name='id' value='$id'/&gt; &lt;input type='submit' value='Sign Up' /&gt; &lt;input type='submit' name='dname' value='Remove Name' /&gt;&lt;/form&gt;" . "&lt;form name='delete' action='delete.php' method='POST'&gt; &lt;input type='hidden' name='id' value='$id'/&gt;"; if(isset($_SESSION['user_id'])){ echo "&lt;input type='submit' name='delete' value='Delete Event' /&gt;&lt;/form&gt;" . "&lt;/td&gt;"; }else{ echo "&lt;/form&gt;" . "&lt;/td&gt;"; } echo "&lt;/tr&gt;"; } echo "&lt;/table&gt;"; echo "&lt;br /&gt;"; } ?&gt; </code></pre> <p>Users can enter a name to sign up and delete their name.</p> <p>The admins can add and delete events. </p> <p>Any suggestions?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload