Note that there are some explanatory texts on larger screens.

plurals
  1. POGet Error from the same value added on the table php
    primarykey
    data
    text
    <p>Hello every one this is simple problem. I am working on a PHP project reserve subject of student. When I click the subject from another table it display to other table dynamically,the problem is how to get the error with the same value that added on the table?</p> <p>here is the code subject:</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' onclick='addRow('myTable')' /&gt; &lt;/td&gt;&lt;/tr&gt;"; $i++; } if (isset($_POST['reserv'])){ if(!empty($_POST['reserv'])){ $a = current(array_keys($_POST['reserv'])); $subj=$_POST['subj'][$a]; $leclab=$_POST['leclab'][$a]; $lab=$_POST['lab'][$a]; $labday=$_POST['labday'][$a]; $desc=$_POST['desc'][$a]; $daylab=$_POST['daylabday'][$a]; $lectlabt=$_POST['lectlabt'][$a]; $labtime=$_POST['labtime'][$a]; $roomLabroom=$_POST['roomlabroom'][$a]; $labroom=$_POST['labroom'][$a]; } } ?&gt; </code></pre> <p>and here is the code that display the subject added:</p> <pre><code>&lt;table border="1" id="myTable" 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; &lt;?php if(isset($_POST['reserv'])){ $_SESSION["S[]"]=array(); $_SESSION["lec[]"]=array(); $_SESSION["lab[]"]=array(); $_SESSION["Day[]"]=array(); $_SESSION["lday[]"]=array(); $_SESSION["lect[]"]=array(); $_SESSION["labt[]"]=array(); $_SESSION["room[]"]=array(); $_SESSION["lroom[]"]=array(); if (isset($_SESSION["counter"])){ $_SESSION["counter"]=$_SESSION["counter"]+1; $counter=$_SESSION["counter"]; }else{$_SESSION["counter"]=0; $counter=$_SESSION["counter"]; } $counter=$_SESSION["counter"]; $_SESSION["S['$counter']"]=$subj; $_SESSION["lec['$counter']"]=$leclab; $_SESSION["lab['$counter']"]=$lab; $_SESSION["Day['$counter']"]=$daylab; $_SESSION["lday['$counter']"]=$labday; $_SESSION["lect['$counter']"]=$lectlabt; $_SESSION["labt['$counter']"]=$labtime; $_SESSION["room['$counter']"]=$roomLabroom; $_SESSION["lroom['$counter']"]=$labroom; $c=0; while($c&lt;=$counter){ if($_SESSION["S['$c']"]==""){echo "-";} echo "&lt;tr&gt;&lt;td&gt;".$_SESSION["S['$c']"] . "&lt;/td&gt; &lt;td&gt;".$_SESSION["lec['$c']"] . "&lt;br/&gt;".$_SESSION["lab['$c']"] . "&lt;/td&gt; &lt;td&gt;".$_SESSION["lect['$c']"] . "&lt;br/&gt;".$_SESSION["labt['$c']"] . "&lt;/td&gt; &lt;td&gt;".$_SESSION["Day['$c']"] . "&lt;br/&gt;".$_SESSION["lday['$c']"] . "&lt;/td&gt; &lt;td&gt;".$_SESSION["room['$c']"] . "&lt;br/&gt;".$_SESSION["lroom['$c']"] . "&lt;/td&gt;&lt;/tr&gt;&lt;br&gt;"; $unit=$_SESSION["lec['$c']"] + $_SESSION["lab['$c']"]; $c=$c+1; $units= $units+$unit; } } echo"&lt;input id='send' name='reset' type='submit' value='reset' /&gt;"; if(isset($_POST['reset'])){ unset($_SESSION['name']); unset($_SESSION['counter']); unset($_SESSION[$_SESSION['counter']]); } ?&gt; </code></pre> <p>thanks in advance</p>
    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.
 

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