Page 1 of 1

[SOLVED] variables

Posted: Sun Aug 08, 2004 8:42 pm
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)

Posted: Sun Aug 08, 2004 9:39 pm
by paladaxar
I think this is what you are looking for:

$RefID="L(".$staffNo.")(".$dateapply.")";

Posted: Sun Aug 08, 2004 10:01 pm
by g3ckO
Tq paladaxar.. solved.

Posted: Sun Jan 28, 2007 2:50 pm
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.

Posted: Sun Jan 28, 2007 3:18 pm
by jayshields
I think you're looking for variable variables.

Posted: Sun Jan 28, 2007 3:34 pm
by tristanlee85

Code: Select all

$form = ${"form_$area1[0]"} . ${"form_$area2[0]"};
Worked just perfectly. Thank you.

Posted: Sun Jan 28, 2007 5:42 pm
by feyd
2.5 year old thread.

Don't necrothread please.