I have two tables:
clients:
id | clients
projprog:
id | clientid | clients | date | subject | post | post by
where clients.id = projprog.clientid
Table clients stores all my current clients and table projprog stores the progress of the projects I am working on. I want to be able to add data to projprog via a form so that clients can view the progress of their projects. This I can do fine but each time I update projprog I need clients.id to be entered into projprog.clientid and this is where I am having trouble.
I think I am on the right lines with the following code but at the moment it is entering multiple rows into my projprog table which I think is due to my select statement:
PHP:--------------------------------------------------------------------------------
<?php
$client = $_POST['client'];
$subject = $_POST['subject'];
$post = $_POST['post'];
$postby = $_POST['postby'];
$date = date("Ymd"
//connect to the DB
include('../db.php');
//set up the first query
$query1 = "SELECT clients.id FROM clients, projprog where clients.id = projprog.clientid";
//run the first query
$result1 = mysql_query($query1, $connection) or die(mysql_error());
while ( $query_row = mysql_fetch_assoc ( $result1 ) )
{
//set up the second query
$query = "INSERT INTO projprog (clientid, clients, date, subject, post, postby) values ('$query_row[id]', '$client', '$date', '$subject', '$post', '$postby')";
//run the second query
$result = mysql_query($query, $connection) or die(mysql_error());
header( "Location: admin.php" );
}
?>
--------------------------------------------------------------------------------
Can anyone offer me any advice on where I am going wrong?
Thankyou in advance....
clients:
id | clients
projprog:
id | clientid | clients | date | subject | post | post by
where clients.id = projprog.clientid
Table clients stores all my current clients and table projprog stores the progress of the projects I am working on. I want to be able to add data to projprog via a form so that clients can view the progress of their projects. This I can do fine but each time I update projprog I need clients.id to be entered into projprog.clientid and this is where I am having trouble.
I think I am on the right lines with the following code but at the moment it is entering multiple rows into my projprog table which I think is due to my select statement:
PHP:--------------------------------------------------------------------------------
<?php
$client = $_POST['client'];
$subject = $_POST['subject'];
$post = $_POST['post'];
$postby = $_POST['postby'];
$date = date("Ymd"
//connect to the DB
include('../db.php');
//set up the first query
$query1 = "SELECT clients.id FROM clients, projprog where clients.id = projprog.clientid";
//run the first query
$result1 = mysql_query($query1, $connection) or die(mysql_error());
while ( $query_row = mysql_fetch_assoc ( $result1 ) )
{
//set up the second query
$query = "INSERT INTO projprog (clientid, clients, date, subject, post, postby) values ('$query_row[id]', '$client', '$date', '$subject', '$post', '$postby')";
//run the second query
$result = mysql_query($query, $connection) or die(mysql_error());
header( "Location: admin.php" );
}
?>
--------------------------------------------------------------------------------
Can anyone offer me any advice on where I am going wrong?
Thankyou in advance....