php - How to select a data from a table using the where and like statement and echo it -


i having issue on how select data database table using , statement.

$hy=mysql_query("select  (total) firstterm                   studentmark, subject                   studentmark.student_id='$name'                     , studentmark.year='$ya'                     , subject.code=studentmark.code                        , studentmark.term='$term' 'f%'");  $hm=mysql_num_rows($hy); $fetch=mysql_fetch_array($hy);  echo $fetch['firstterm']; 

the issue 'f%' (first) in term has 89 total not selected in table 's%' (second) in term has 73 selected. there missing?

the table below

term   | code |student_id|contass20asg|classwk10 |test2nd10|year |exam| total first  | agr  | john     |  18        |5         |   7     |2011 | 59 |   89 second |agr2  |john      |  13        |6         |   4     |2011 | 40 |   73 third  |agr3  |john      |  18        |6         |   8     |2011 | 34 |   64 first  |bio   |john      |  12        |3         |   3     |2011 | 55 |   73 second |bio2  |john      |  14        |8         |   7     |2011 | 56 |   85 third  |bio3  |john      |  12        |8         |   8     |2011 | 42 |   70 

my code stated below

<?php echo '</td><td>'?>   <?php      if ($fetch['total']==null){ echo 'missed'; }else      $hy=mysql_query("select  (total) secondterm studentmark, subject studentmark.student_id='$name' , studentmark.year='$ya' , subject.code=studentmark.code    , studentmark.term='$term' 's%'"); $hm=mysql_num_rows($hy); $fetch=mysql_fetch_array($hy); echo $fetch['secondterm']; ?> <?php echo '</td><td>'?>   <?php      if ($fetch['total']==null){  }else      $hy=mysql_query("select  (total) firstterm studentmark, subject studentmark.student_id='$name' , studentmark.year='$ya' , subject.code=studentmark.code    , studentmark.term='$term' 'f%'"); $hm=mysql_num_rows($hx);  $hm=mysql_num_rows($hy); $row=mysql_fetch_array($hy); echo $row['secondterm'];   ?>  <?php echo '</td><td>'?>   <?php      if ($fetch['total']==null){ //echo 'missed'; }else      $hy=mysql_query("select  (total) thirdterm studentmark, subject studentmark.student_id='$name' , studentmark.year='$ya' , subject.code=studentmark.code    , studentmark.term='$term'"); $hm=mysql_num_rows($hy);  $hm=mysql_num_rows($hy); $fetch=mysql_fetch_array($hy); $row=mysql_fetch_array($hy);  echo $fetch['firstterm']+ $row['secondterm'] + $fetch['thirdterm'];  ?> 

like operator comparison, need use operator '=','>' etc.

studentmark.term '%someval%'; 

hope answers question.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -