Hello,
I don't have any errors it just not showing a thing if i leave only the html code it works but in php it wont so if you can help me would be cool, Thanks =]

<?php 
$a = trim($_REQUEST['a']);  
$student = trim($_GET['student']);
if($a == 'edit' and !empty($id))
{  
    /* zapytanie do tabeli */  
    $wynik = mysql_query("SELECT * FROM table_name WHERE student='$student'")  
    or die('Błąd zapytania');  
    if(mysql_num_rows($wynik) > 0)
   {   
   $r = mysql_fetch_assoc($wynik);
   echo '<form action="edycja.php" method="post">
   <input type="hidden" name="a" value="save" />
   <input type="hidden" name="student" value="'.$student.'"/>
   test1:<br />
   <input type="text" name="test1" value="'.$r['test1'].'"/><br />
   test2:<br />
   <input type="text" name="test2" value="'.$r['test2'].'" /><br /> 
   <input type="text" name="test3" value="'.$r['test3'].'" /><br />
   <input type="submit" value="popraw" />
   </form>';  

  
    }  
} 

elseif($a == 'save')
{  
    /* odbieramy zmienne z formularza */  
    $student = $_POST['student'];  
    $test1 = trim($_POST['test1']);  
    $test2 = trim($_POST['test2']);  
    $test3 = trim($_POST['test3']); 
    /* uaktualniamy tabelę test */  
    mysql_query("UPDATE test SET test1='$test1',  
    test2='$test2, test3='$test3' WHERE student='$student'")  
    or die('Błąd zapytania');  
    echo 'Dane zostały zaktualizowane';  
} 
?>
Member Avatar for P0lT10n

what is your problem ??? post the code that works... i think that it dont work because you have to replase the if condition (if(mysql_num_rows($wynik) > 0) for a while condition (while($r = mysql_fetch_assoc($wynik)){) but before do the if result is > 0...

Hello,
I don't have any errors it just not showing a thing if i leave only the html code it works but in php it wont so if you can help me would be cool, Thanks =]

<?php 
$a = trim($_REQUEST['a']);  
$student = trim($_GET['student']);
if($a == 'edit' and !empty($id))
{  
    /* zapytanie do tabeli */  
    $wynik = mysql_query("SELECT * FROM table_name WHERE student='$student'")  
    or die('Błąd zapytania');  
    if(mysql_num_rows($wynik) > 0)
   {   
   $r = mysql_fetch_assoc($wynik);
   echo '<form action="edycja.php" method="post">
   <input type="hidden" name="a" value="save" />
   <input type="hidden" name="student" value="'.$student.'"/>
   test1:<br />
   <input type="text" name="test1" value="'.$r['test1'].'"/><br />
   test2:<br />
   <input type="text" name="test2" value="'.$r['test2'].'" /><br /> 
   <input type="text" name="test3" value="'.$r['test3'].'" /><br />
   <input type="submit" value="popraw" />
   </form>';  

  
    }  
} 

elseif($a == 'save')
{  
    /* odbieramy zmienne z formularza */  
    $student = $_POST['student'];  
    $test1 = trim($_POST['test1']);  
    $test2 = trim($_POST['test2']);  
    $test3 = trim($_POST['test3']); 
    /* uaktualniamy tabelę test */  
    mysql_query("UPDATE test SET test1='$test1',  
    test2='$test2, test3='$test3' WHERE student='$student'")  
    or die('Błąd zapytania');  
    echo 'Dane zostały zaktualizowane';  
} 
?>

Please clarify your question.. Its not clear to me.

Hello,
I want to have 3 forms: "test1", "test2","test3" that shows the informasion from record and i can edit them and save into DB, I dont know why but on the site its not showing the forms

Try this:

<?php 
$a = trim($_REQUEST['a']);  
$student = trim($_GET['student']);
if($a == 'edit' and !empty($id))
{  
    /* zapytanie do tabeli */  
    $wynik = mysql_query("SELECT * FROM table_name WHERE student='$student'")  
    or die('Błąd zapytania');  
    while($r = mysql_fetch_assoc($wynik))
	{
	   echo '<form action="edycja.php" method="post">
	   <input type="hidden" name="a" value="save" />
	   <input type="hidden" name="student" value="'.$student.'"/>
	   test1:<br />
	   <input type="text" name="test1" value="'.$r['test1'].'"/><br />
	   test2:<br />
	   <input type="text" name="test2" value="'.$r['test2'].'" /><br /> 
	   <input type="text" name="test3" value="'.$r['test3'].'" /><br />
	   <input type="submit" value="popraw" />
	   </form>';  
    }  
} 

elseif($a == 'save')
{  
    /* odbieramy zmienne z formularza */  
    $student = $_POST['student'];  
    $test1 = trim($_POST['test1']);  
    $test2 = trim($_POST['test2']);  
    $test3 = trim($_POST['test3']); 
    /* uaktualniamy tabelę test */  
    mysql_query("UPDATE test SET test1='$test1',  
    test2='$test2, test3='$test3' WHERE student='$student'")  
    or die('Błąd zapytania');  
    echo 'Dane zostały zaktualizowane';  
} 
?>

Hello,
thanks but i now see what was wrong and ive change the code like hell got some problems with editing it but hope will fix it thanks =]

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.