[SOLVED] variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
User avatar
g3ckO
Forum Contributor
Posts: 117
Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:

[SOLVED] variables

Post by g3ckO »

Code: Select all

<?php
include("database.php");

define('HOST', 'localhost');
define('USER', 'root');
define('PASS', '');
define('DB', 'db1');


 	$staffNo = $_POST['StaffNo'];
	$dateapply = $_POST['dateapply'];

	$RefID = ?????	


   global $conn;
   $q = "INSERT INTO leave VALUES ('$dateapply')";
   mysql_query($q,$conn);

?>
I want to store the value of $RefID by combining the value of $staffNo and $dateapply in this format:

L($staffNo)($dateapply)

How should I write it? (the value of $RefID)
paladaxar
Forum Commoner
Posts: 85
Joined: Fri Jun 18, 2004 11:50 pm

Post by paladaxar »

I think this is what you are looking for:

$RefID="L(".$staffNo.")(".$dateapply.")";
User avatar
g3ckO
Forum Contributor
Posts: 117
Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:

Post by g3ckO »

Tq paladaxar.. solved.
tristanlee85
Forum Contributor
Posts: 172
Joined: Fri Dec 19, 2003 7:28 am

Post by tristanlee85 »

I think this falls into this category, but a bit different. Basically, I have 4 different $form variables that will be used depending on the user.

For instance, if

Code: Select all

$area1[0]
has a value of 3, I would like

Code: Select all

$form = $form_3;
. Since $area1[0] is different for every user, I've been trying to do something like this:

Code: Select all

$form = $form_[$area1[0]];
Does that make sense? Of course, with that code, I get nothing to work.
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

I think you're looking for variable variables.
tristanlee85
Forum Contributor
Posts: 172
Joined: Fri Dec 19, 2003 7:28 am

Post by tristanlee85 »

Code: Select all

$form = ${"form_$area1[0]"} . ${"form_$area2[0]"};
Worked just perfectly. Thank you.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

2.5 year old thread.

Don't necrothread please.
Locked