Current location: Hot Scripts Forums » General Community » Script Requests » PHP: Different table entry from same form?


PHP: Different table entry from same form?

Reply
  #1 (permalink)  
Old 05-04-05, 10:50 AM
Stormrider Stormrider is offline
New Member
 
Join Date: May 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
PHP: Different table entry from same form?

Hi everyone! I am new here as well as in php... getting the hang of it is a bit... odd but I like it really really much.. So um let's go to my first question

I have a data entry form on my webpage "manager" and what I would like to do is have a list box in it so when I set it to one value the data on the form, on Submit, gets improrted in one certain table in the MySQL DB and when I set it to the other value it gets inbserted elsewhere.

I.e. I have 2 tables in my DB called "links" and "b_links". The have the same number and type of fields. so what I would like to do is have one form that can insert data to the table to tell it to by using the list box, rather than have 2 different forms.

Thabk you in advance!
-Storm
Reply With Quote
  #2 (permalink)  
Old 05-06-05, 08:13 AM
diamondwolf diamondwolf is offline
New Member
 
Join Date: Apr 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
when you hit submit you just want two ifs really

and you check the value of $_POST['linkvalues'] or $_GET['linkvalues'] depending on which value you get from the select box

// so login details
<?php

$link = mysql_connect($server,$username,$password);
mysql_select_db($databasename);
if ($_POST['linkvalues'] == "whatever1")
{
$query = $query = "INSERT INTO links SET field ='".$titlename."',";
}

if ($_POST['linkvalues'] == "whatever2")
{
$query = $query = "INSERT INTO links2 SET field ='".$titlename."',";
}
$result = mysql_query($query);
?>

thats all there is to it
Reply With Quote
  #3 (permalink)  
Old 05-07-05, 01:27 AM
infinitylimit's Avatar
infinitylimit infinitylimit is offline
Code Guru
 
Join Date: Jun 2004
Location: Oregon
Posts: 758
Thanks: 0
Thanked 0 Times in 0 Posts
If your listbox supplies the name of the table you could just write you sql query as so

'INSERT INTO '.$_POST['listbox'].'(value1,value2,value3,value4) VALUES ("....'

You follow? List box would be the table name.
__________________
Hawk Enterprises -- Home to PHP games, open-source code, tutorials and free downloads
Reply With Quote
  #4 (permalink)  
Old 05-07-05, 08:19 AM
Stormrider Stormrider is offline
New Member
 
Join Date: May 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Yeah I think I do. As I've said, I am new to php so I try to learn alot of things at once which is not so easy heh
In anycase, although I WILL try out what you guys suggested, I have worked my way around my prob by inserting everythig into one instead of two tables, BUT giving the table an extra field which helps me filter out via SQL the records that I want to present on a webpage.

Thx guys!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2 profitable script sites for sale cms-master.com General Advertisements 3 07-03-07 10:17 AM
DB entry thru php form question ajs PHP 3 03-21-05 09:07 AM
Help - Dynamically create a table using PHP pink-fairy PHP 3 03-07-05 07:19 PM
Competition entry form / random entry draw script with PHP? Tim Smith PHP 0 08-12-04 01:45 AM
Problem with table and form gharryh HTML/XHTML/XML 2 08-05-04 11:47 PM


All times are GMT -5. The time now is 11:43 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.