Javascript in php

Posted by user506539 on Stack Overflow See other posts from Stack Overflow or by user506539
Published on 2010-12-21T04:25:48Z Indexed on 2010/12/21 5:00 UTC
Read the original article Hit count: 115

Filed under:
|

I have a form where user enters category, it gets inserted into db and it has to go to other page to select an image, after selection image id has to get into category table.

I am doing some thing like this

<?php
error_reporting(E_ALL ^ E_NOTICE);
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("mydocair", $con);

$ThirdPartyCategoryName =$_POST['ThirdPartyCategoryName'];

$checkformembers = mysql_query("SELECT * FROM thirdpartycategorymaster WHERE ThirdPartyCategoryName = '$ThirdPartyCategoryName'");
if(mysql_num_rows($checkformembers) != 0)
{
    header('location:newcat.php?msg=category exists');
}
else
{
    $sql="INSERT INTO  thirdpartycategorymaster (ThirdPartyCategoryID, ThirdPartyCategoryName)
    VALUES
    ('$_POST[ThirdPartyCategoryID]',
    '$_POST[ThirdPartyCategoryName]'
    )";
}
if (!mysql_query($sql,$con))
  {
      die('Error: ' . mysql_error());
  }

mysql_close($con);
?>
<?php
$res = mysql_query("SELECT ThirdPartyCategoryID FROM  thirdpartycategorymaster");

while($row = mysql_fetch_array($res))
  {
"<script type='text/javascript'>
 if(window.confirm("Do you want to insert image for category?")) {
  document.location = "imgcat.php?id="<?php echo row2['ThirdPartyCategoryID']; ?>""
}
</script>";
}
?>

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript