Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

pa help po sa php

djparashort

Recruit
Basic Member
Messages
7
Reaction score
0
Points
16
paano po ba mag insert ng isang value second table if exists cya table1
table 1
if(isset(&_POST['submit'])){
$studentid=&_POST['studentidnum'];
$firstname=&_POST['firstname'];
$lastname=&_POST['lastname'];

$query = "insert into table1 (studentidnum,firstname,lastname) values('$studentid','$firstname',$lastname')";
$result = mysql_query($query) or die ('error');

ang gusto ko po kapag ang user mag input ng student id number dapat exists cya sa table1 if exists insert cya sa table2 at kng hindi exists may link na register
please help po anong e code ko
thanks po
 
paano po ba mag insert ng isang value second table if exists cya table1
table 1
if(isset(&_POST['submit'])){
$studentid=&_POST['studentidnum'];
$firstname=&_POST['firstname'];
$lastname=&_POST['lastname'];

$query = "insert into table1 (studentidnum,firstname,lastname) values('$studentid','$firstname',$lastname')";
$result = mysql_query($query) or die ('error');

ang gusto ko po kapag ang user mag input ng student id number dapat exists cya sa table1 if exists insert cya sa table2 at kng hindi exists may link na register
please help po anong e code ko
thanks po

----------------------------
CHANGES/UPDATES


if(isset($_POST['submit'])){
$studentid=$_POST['studentidnum'];
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];

$query = "insert into table1 (studentidnum,firstname,lastname) values('$studentid','$firstname','$lastname')";
$result = mysql_query($query) or die ('error');

$query2 = "SELECT `studentidnum` FROM table2 WHERE `studentidnum`='$studentid'";
$result2 = mysql_query($query2);
$num2 = mysql_num_rows($result2);

if($num2>0) {
//INSERT INTO TABLE2
} else {
echo "<a href="#">Go to Link</a>";
}

}

------------------------------
Check mu rin
sana nakatulong :)
 
paano po ba mag insert ng isang value second table if exists cya table1
table 1
if(isset(&_POST['submit'])){
$studentid=&_POST['studentidnum'];
$firstname=&_POST['firstname'];
$lastname=&_POST['lastname'];

$query = "insert into table1 (studentidnum,firstname,lastname) values('$studentid','$firstname',$lastname')";
$result = mysql_query($query) or die ('error');

ang gusto ko po kapag ang user mag input ng student id number dapat exists cya sa table1 if exists insert cya sa table2 at kng hindi exists may link na register
please help po anong e code ko
thanks po

hmm.. sorry huh.. ang vague kasi ng question mo sir..

Ano po ba ang gusto mo gawin.?

Kung registration yan sir..

May 2 kang option dyan.. kung yung student in No. ang problema mo..

Una.. Is MagAuto Generate ka ng Student ID..

Para macontrol mo yung pagkakaroon ng Double entry..

Now dun tayo sa 2nd option.. at yung gusto mong mangyari..

Ang gusto mo makita kung existing ba yung student id no. sa table 1..

Ang gagawin mo jan.. is ifetch mo muna yung studentidno sa table 1..


Gagawin mo..

Tignan mo muna sa Table 1 kung existing ang Student ID no sa Table 1..
////////////////////////////////////////////////////////////////////
$studentid=&_POST['studentidnum'];
$firstname=&_POST['firstname'];
$lastname=&_POST['lastname'];

$db = mysqli_connect('localhost', 'username', 'password', 'database');
if($query = mysqli_query($db, "SELECT studentidnum FROM table1 WHERE studentidnum = '$studentid'")) //check if the student ID no. is existing in table 1
{
while($row = mysqli_fetch_assoc($query)){ //if student id No. is existing
$query2 = mysqli_query($db, "INSERT INTO table2 (studentindnum) VALUES ('$studentid'); //Insert the value in Table 2.
}
// if value does not exist
echo "Student ID no. doesn't exist. Would you like to". "<a href="register.php">"."register";

mysqli_free_result($query);
}
////////////////////////

Hope this would help you.. :)
 
Back
Top Bottom