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';  
} 
?>
3
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by BoB3R
0

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...

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.

Edited by vibhaJ: n/a

0

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

1

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';  
} 
?>
0

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 =]

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.