PHP Help.... Again
Discussion
I use the following query in a PHP form/script.
SELECT DISTINCT CONCAT( surname, ', ', givenname ) AS full_name, Y.adocid as DOCID
FROM trusr as X
LEFT OUTER JOIN proc as Y ON Y.ADOCID = X.uid
WHERE givenname IS NOT NULL AND surname IS NOT NULL
ORDER BY full_name
This query returns a concatenation of given and surname to populate a dropdown list to select individuals (full_name) and it works just fine. I can pass the variable via a POST to my php action.
(The query is good if I run it natively in MySQl and returns the data I expect. two columns, full_name and DOCID)
I want to also pass the variable DOCID from above to the php action. I added # in the the PHP script, because it creates a dropdown in the post otherwise!!!!
<?#php #_POST[fullname] and #_POST[DOCID]; ?#>
<#select name="DocName" id="DocName">
<?#php
do {
#?>
<option value="<?#php echo $row_Recordset1['full_name']?>"><?#php echo $row_Recordset1['full_name']?></option>
<?#php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
$rows = mysql_num_rows($Recordset1);
if($rows > 0) {
mysql_data_seek($Recordset1, 0);
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
}
#?>
Any ideas how I can proceed? All I want to do is reference DOCID as $DOCID to pass into a SQL query on the PHP script which forms the action of the form... Err, if you see what I mean!
I can post the full PHP scripts if anyone is willing to help... It's all in a good cause again
Thanks
EDIT:
It was very late and I was tired when I first posted this!
>>> Edited by BliarOut on Sunday 19th September 11:08
SELECT DISTINCT CONCAT( surname, ', ', givenname ) AS full_name, Y.adocid as DOCID
FROM trusr as X
LEFT OUTER JOIN proc as Y ON Y.ADOCID = X.uid
WHERE givenname IS NOT NULL AND surname IS NOT NULL
ORDER BY full_name
This query returns a concatenation of given and surname to populate a dropdown list to select individuals (full_name) and it works just fine. I can pass the variable via a POST to my php action.
(The query is good if I run it natively in MySQl and returns the data I expect. two columns, full_name and DOCID)
I want to also pass the variable DOCID from above to the php action. I added # in the the PHP script, because it creates a dropdown in the post otherwise!!!!
<?#php #_POST[fullname] and #_POST[DOCID]; ?#>
<#select name="DocName" id="DocName">
<?#php
do {
#?>
<option value="<?#php echo $row_Recordset1['full_name']?>"><?#php echo $row_Recordset1['full_name']?></option>
<?#php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
$rows = mysql_num_rows($Recordset1);
if($rows > 0) {
mysql_data_seek($Recordset1, 0);
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
}
#?>
Any ideas how I can proceed? All I want to do is reference DOCID as $DOCID to pass into a SQL query on the PHP script which forms the action of the form... Err, if you see what I mean!
I can post the full PHP scripts if anyone is willing to help... It's all in a good cause again
Thanks
EDIT:
It was very late and I was tired when I first posted this!
>>> Edited by BliarOut on Sunday 19th September 11:08
Not too sure on your script but what I'd normally do is
echo "<select name="chosenID">";
$result=mysql_query("select ID,Name from xxxxx");
while ($row=mysql_fetch_array($result)) {
echo "<option value="".$row["ID"]."">".$row["Name"];
}
you can then refer to the field in the relevant script as $chosenID or perhaps $HTTP_POST_VARS["chosenID"] if you haven't got register_globals on
echo "<select name="chosenID">";
$result=mysql_query("select ID,Name from xxxxx");
while ($row=mysql_fetch_array($result)) {
echo "<option value="".$row["ID"]."">".$row["Name"];
}
you can then refer to the field in the relevant script as $chosenID or perhaps $HTTP_POST_VARS["chosenID"] if you haven't got register_globals on
Thanks very much for the offer, I have just sussed it!
What worked was something like.
$row_Recordset1'[DOCID]$row_Recordset1['full_name'] (Lots of bits stripped out to display it here)
I was trying to do something similar to an Access "bound column" but hadn't got my head round a select option.
ie. store this value, but display the other value.
I'll tidy up the code like you suggested though!
Thanks for offering!
What worked was something like.
$row_Recordset1'[DOCID]$row_Recordset1['full_name'] (Lots of bits stripped out to display it here)
I was trying to do something similar to an Access "bound column" but hadn't got my head round a select option.
ie. store this value, but display the other value.
I'll tidy up the code like you suggested though!
Thanks for offering!
Gassing Station | Computers, Gadgets & Stuff | Top of Page | What's New | My Stuff


