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);

?>

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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