0

Possible Duplicate:
How would I add a message that says “$user_id Deleted” or “$user_id not found?”

<?php
  error_reporting(0);
  $con=mysql_connect("localhost","root","");

  if (!$con) {
    die('could not connect:'.mysql_error());
  }

  mysql_select_db("final?orgdocs",$con);

  $org_name = $_POST["org_name"];
  $org_type = $_POST["org_type"];
  $org_code = $_POST["org_code"];
  $description = $_POST["description"];

  $stmt = "INSERT INTO organization
           VALUES('".$org_name."','".$org_type."','".$org_code."','".$description."')";
  $result = mysql_query("SELECT * FROM organization WHERE org_name = '$org_name' ");

  echo '<TABLE BORDER = "1">';
  $result1 = $result;

  while ($row = mysql_fetch_array($result1)){
    echo '<TR>'.'<TD>'.'Organization Name'.'</TD>'.'<TD>'.'Organization Type'.'</TD>'.'<TD>'.'Organization Code'.'</TD>'.'<TD>'.'Description'.'</TD>'.'<TD>'.'Constitution'.'</TD>';
    echo '</TR>';
    echo '<TR>'.'<TD>'.$row['org_name'].'</TD>'.'<TD>'.$row['org_type'].'</TD>';
    echo '<TD>'.$row['org_code'].'</TD>'.'<TD>'.$row['description'].'</TD>'.'<TD>';
    echo '</TR>';
  }    
  echo '</TABLE>';
?>
Community
  • 1
  • 1
ranlo
  • 19
  • 4
  • 5
    Dude. **Exactly** the same way as in your previous question. Are you going to learn anything from the answers you get? – Your Common Sense Jan 02 '11 at 10:38
  • 2
    You're not actually running the insert query? And please stop posting just heaps of code for every step, and start *learning*. – Pekka Jan 02 '11 at 10:38
  • @ranlo: This is a copy-pasted chunk of source code along with an instruction what people should code for you. In short: It's not a real question. – Tomalak Jan 02 '11 at 10:41
  • @ranlo by the way, your code is vulnerable to SQL injection. You should fix that – Pekka Jan 02 '11 at 10:42
  • @ranlo just start asking more specific questions (e.g. "How to find out the number of inserted rows after a mySQL query") and show less code, just the relevant bits. Have the PHP manual handy, e.g. on [mySQL functions](http://www.php.net/manual/en/ref.mysql.php) . – Pekka Jan 02 '11 at 10:49
  • what sql injection?sorry i'm kinda new in php-mysql – ranlo Jan 02 '11 at 10:51
  • i do have another problem with this code,when the values are already submitted, it won't show your inputted values right after it's submission, you'll have to refresh the page before you can see your newly submitted values,how will i fix that? – ranlo Jan 02 '11 at 10:53
  • @ranlo you will probably have to put the insert block before the output block. Re SQL injection, see e.g. here: http://stackoverflow.com/questions/332365/xkcd-sql-injection-please-explain – Pekka Jan 02 '11 at 11:40

2 Answers2

0
    $count = mysql_affected_rows();
    echo "$count values inserted to table”;
Ass3mbler
  • 3,855
  • 2
  • 20
  • 18
0

Shortest answer : echo 'values inserted to table';

Shikiryu
  • 10,180
  • 8
  • 49
  • 75
  • aww come on, some humor on question like this, no? Plus, that **does** answer the question which is _How would i output a message that says “values inserted to table” ?_ (the code below the title doesn't express anything more.) – Shikiryu Jan 03 '11 at 07:13