Jump to content

how to display the data had by a html form, in a div in the same page?


it works!!!

Recommended Posts

After posting  the selected category and the subcategory the names of respective objects from the DATABASE in div "objects" ne the same page with the form that has this layout:

html_form.png

 

this is the php code:

 

<?php

include("dbinfo.php");

$connection = mysql_connect("server",$username,$password);

if (!$connection) {

die('Not connected : ' . mysql_error());

}

$db_selected = mysql_select_db($database, $connection);

if (!$db_selected) {

die ('Can\'t use db : ' . mysql_error());

}

$result1=mysql_query("Select idg from Grupimi where grupim='$_POST[category]' and detaje='$_POST[subcategory]'") or die(mysql_error()); 

$row1 = mysql_fetch_array($result1);

$klasifikimi = $row1['idg'];

$result2=mysql_query("Select oemer from Objekt where klasifikimi='$klasifikimi'") or die(mysql_error()); 

<?

}else{

while($row2 = mysql_fetch_array($result2)){

  echo $row2['oemer'];

  echo "<br/>";

}

}

mysql_close($connection);

?>

OK where's the PHP code - that's just the HTML?

 

You can do what I do and incorporate your PHP and HTML into one page - here's an example...

<?php
  $strName=$_POST['name'];
  if ($_POST['subshow']) {
    //user clicked submit so validate here
  }
?>
<html>
<head>
  <title>My Page</title>
</head>
<body>
  <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
    Name: <input type="text" name="name" value="<?=$strName?>" /><br />
    <input type="submit" name="subshow" value="Show Data" />
  </form>
  You entered: <?=$strName?>
</body>
</html>

 

EDIT: When showing data inside a textbox do it like this:

<textarea name="mytextbox" cols="40" rows="7"><?=$txtSomeText?></textarea>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.