Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding a dynamic row into an existing html with php
    primarykey
    data
    text
    <p>I would like to add new ROWS and COLUMNS into another existing TABLE within the same page. How could I do that easily?</p> <p>Here is the code:</p> <pre><code>$sql = mysql_query("SELECT * FROM tblsubjecschedule ORDER BY Subject"); $i=0; $b =1; while($row=mysql_fetch_assoc($sql) ){ echo "&lt;tr&gt;&lt;td&gt;".$row['Subject']."&lt;input type='hidden' name='subj[$i]' value=".$row['Subject']."&gt;&lt;/td&gt; &lt;td&gt;".$row['Lec']."&lt;br/&gt;".$row['Lab']."&lt;input type='hidden' name='leclab[$i]' value=".$row['Lec']."&gt;&lt;input type='hidden' name='lab[$i]' value=".$row['Lab']."&gt;&lt;/td&gt; &lt;td&gt;".$row['Descriptive']."&lt;input type='hidden' name='desc[$i]' value=".$row['Descriptive']."&gt;&lt;/td&gt; &lt;td&gt;".$row['Day']."&lt;br/&gt;".$row['Labday']."&lt;input type='hidden' name='daylabday[$i]' value=".$row['Day']."&gt;&lt;input type='hidden' name='labday[$i]' value=".$row['Labday']."&gt;&lt;/td&gt; &lt;td&gt;".$row['LecTime']."&lt;br/&gt;".$row['LabTime']."&lt;input type='hidden' name='lectlabt[$i]' value=".$row['LecTime']."&gt;&lt;input type='hidden' name='labtime[$i]' value=".$row['LabTime']."&gt;&lt;/td&gt; &lt;td&gt;".$row['Room']."&lt;br/&gt;".$row['Labroom']."&lt;input type='hidden' name='roomlabroom[$i]' value=".$row['Room']."&gt;&lt;input type='hidden' name='labroom[$i]' value=".$row['Labroom']."&gt;&lt;/td&gt; &lt;td&gt;&lt;input id='send' name='reserv[$i]' type='submit' value='Add' [$b] /&gt;&lt;/td&gt;&lt;/tr&gt;"; $i++; } ?&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;table border="1" style='width: 900px;'&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;SubjectCode &lt;th&gt;Units &lt;th&gt;Time &lt;th&gt;Day &lt;th&gt;Room&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; </code></pre> <p>and this is where I display the data but it displays one row only</p> <pre><code>&lt;?php if (isset($_POST['reserv'])){ if(!empty($_POST['reserv'])){ $i = current(array_keys($_POST['reserv'])); $subj=$_POST['subj'][$i]; $leclab=$_POST['leclab'][$i]; $lab=$_POST['lab'][$i]; $labday=$_POST['labday'][$i]; $desc=$_POST['desc'][$i]; $daylab=$_POST['daylabday'][$i]; $lectlabt=$_POST['lectlabt'][$i]; $labtime=$_POST['labtime'][$i]; $roomLabroom=$_POST['roomlabroom'][$i]; $labroom=$_POST['labroom'][$i]; } } if (isset($_POST['reserv'])){ $count=0; $a=0; $c=current(array_keys($_POST['reserv'])); if (!empty($c)){ $a=1; for ($count;$count&lt;=$a;$count++){ echo "&lt;tr&gt; &lt;td&gt;".$subj."&lt;/td&gt; &lt;td&gt;".$leclab."&lt;br/&gt;".$lab."&lt;/td&gt; &lt;td&gt;".$lectlabt."&lt;br/&gt;".$labtime."&lt;/td&gt; &lt;td&gt;".$daylab."&lt;br/&gt;".$labday."&lt;/td&gt; &lt;td&gt;".$roomLabroom."&lt;br/&gt;".$labroom."&lt;/td&gt; &lt;/tr&gt;"; } } } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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