mtvaran
-
Posts
61 -
Joined
-
Last visited
Never
Posts posted by mtvaran
-
-
wow... ur genius Adam, now it works. thank you so mch for ur help. hope you will be bearing with me for helping in future. thanks again.
thank you my other guys for ur kind reply.
-
Adam, i cudn't correcr errors. this is my code..... can you pls have a look....
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("uni", $con);
$sql="INSERT INTO Student (StudentID,StudentName)
VALUES ('$_POST[sid]','$_POST[sname]')";
if(!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
if (!preg_match('/^[0-9]{7}$/', $_POST['sid']))
{
echo"existing id ......... "; // invalid
}
$sql = "SELECT StudentID FROM student WHERE StudentID =" . $sid;
$query = mysql_query($sql); or trigger_error('MySQL error: ' . mysql_error());
if (mysql_num_rows($query) > 0)
{
echo"id already taken......";// already taken
}
mysql_close($con)
?>
-
first of all thank you so much for the help. i meant the existing value was if i already entered the same ID then i cant enter again. if you can help me pls... thanks
-
hi guys, in my form i need to insert an ID which is 5 digits number only. can anyone please tell me how can i check this before i insert? and also i need to check existing ID in my database.
-
sorry guys, I COULD NOT GET IT. i know im bit stupid. all i want is i have already displayed data from two table one is drop-down list another one multi select list, now i need to select one data from drop-down list and one or more data from multi select list then send to another table. hope i made this clear for you guys. plss if you can help me...
-
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_DB_name", $con);
$result = mysql_query("SELECT * FROM buy");
echo "<select multiple='multiple'>";
while($row = mysql_fetch_array($result))
{
echo "<option value=''>";
echo $row['ID'];
echo "</option>";
}
echo "</select>";
mysql_close($con);
?>
this is the code im using to display data as select list. but i need a code for select data from that and insert ito another table.
-
could anyone please help me with the code which is i have already displayed data as a multi select list but now i need to select one or more from them and insert into another database table. would be appreciate your help. thanx
check data type and value
in PHP Coding Help
Posted
pls any1 tell me this simple code for preg_match ............. "only allowing a-z & A-Z in text field" not nubmer things