php - can't retrieve all rows from a table -


i've tried past hour figure way server recognize if user owns similar row in mysql db

can of guys me...

here code ive done now

$nummer = $_get['a']; $klasse = strtoupper ( $_get['b'] );  $kid = $nummer . '.' . $klasse;  $result = $db->query("select kid kcode sid='".$_session['id']."'"); $resa = $result->fetch();  $b = strtoupper ( $resa['kid'] ); $a = $kid $c = $_session['id'];    if ($a !== $b){ echo "insert"; } else { echo "already exists"; } 

ok explain deeper different commands is:

  • $_get['a']=a letter retrieved previous page
  • $_get['b']=a number retrieved previous page

"kid" wich wanna select row in kcode table, problem there several kid's want compare $a... when try way retrieve last created.

thx time

edit: said in comment want compare $kid mysql rows called kid when sid=$_session['id'].

if want retrieve multiple rows, need put fetch in loop:

$exists = false;  while($resa = $result->fetch()) {      $b = strtoupper ( $resa['kid'] );     $a = $kid     $c = $_session['id'];      if ($a !== $b){         //echo "insert";     } else {         $exists = true;         //echo "already exists";     } }   if($exists){ {     echo "already exists"; } else {     echo "insert"; } 

is trying do?

now, if trying see if row exists, should modify query:

$result = $db->query("select kid kcode sid='".$_session['id']."'                        , kid='$kid'"); 

since getting $kid get parameters, need clean first, prevent sql injection.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -