TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-02-2011, 10:00 PM   #1 (permalink)
The Wanderer
 
Join Date: May 2011
Posts: 9
Thanks: 0
destroyerx15 is on a distinguished road
Default hwo to select forgin key to insert to another table

hi guys
im beginner in php


i have another question

how to insert foreign key to another table to insert

i use like this for my form that have staff_id and password

my form of login :

<form action="2.php" method="post">
staff_id : <input type="text" name="staff_id" />
STAFF_PASSWORD: <input type="text" name="STAFF_PASSWORD" />
<input type="submit" name="login" value="login"/>
</form>

and for php

i use like this :


Welcome <?php echo $_POST["staff_id"];
include("config.php");

$result = mysql_query("SELECT staff_id FROM orders WHERE staff_id=('SELECT staff_id FROM staffs ')");



?>
<table class="table">
<form action="11.php" method="post">
<tr>


<th class="th">ORDER_DESC </th>

</tr>
<tr>
<td class="td"><input type="checkbox" name="checkbox[]" value="CSF"/> CSF </td>
</tr>

<tr>
<td class="td"><input type="checkbox" name="checkbox[]" value="LFT"/> LFT </td>
</tr>

<tr>
<td class="td"><input type="checkbox" name="checkbox[]" value="RFR"/> RFR </td>
</tr>


<tr>
<td class="td"><input type="checkbox" name="checkbox[]" value="TFT"/> TFT </td>
</tr>

<tr>
<td class="td" ><input type="submit" value="Submit" name="Submit"/>
</td>
</tr>
</form>
</table>

i using nested select but no relation between two db so i have table called orders that have staff_id is forign key

can any help and tnx for solving my problem
destroyerx15 is offline  
Reply With Quote
Old 06-03-2011, 01:21 AM   #2 (permalink)
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default

I don't seem to understand your problem, but I am guessing you want all the orders that have a staff_id that exists in the staffs table. If that is the case, you can do a left join:

SQL Code:
SELECT orders.staff_id
FROM orders
LEFT JOIN staffs ON orders.staff_id = staffs.staff_id
tony is offline  
Reply With Quote
Old 06-03-2011, 01:36 AM   #3 (permalink)
The Wanderer
 
Join Date: May 2011
Posts: 9
Thanks: 0
destroyerx15 is on a distinguished road
Default

not work the left join
destroyerx15 is offline  
Reply With Quote
Old 06-12-2011, 07:48 AM   #4 (permalink)
The Wanderer
 
Join Date: Dec 2008
Location: Houston, TX
Posts: 14
Thanks: 1
mjwalsh is on a distinguished road
Default

Can you try to explain your issue a little more?
Send a message via AIM to mjwalsh Send a message via MSN to mjwalsh
mjwalsh is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
feedback on my class please frostyboy33 Advanced PHP Programming 7 10-22-2012 09:12 AM
Databse structure Village Idiot TalkPHP Developer Team 3 01-16-2009 10:31 PM
This project has begun! Village Idiot TalkPHP Developer Team 40 01-01-2009 04:29 AM
how to insert html or php code into a table? sarmenhb Absolute Beginners 7 09-07-2008 12:23 PM
how to insert data from a incrimented table row into the db sarmenhb Absolute Beginners 3 06-27-2008 01:15 AM


All times are GMT. The time now is 02:48 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design