Assign Javascript Variable To PHP Variable
i have select option on my website.When i choose select option the value of selecet option which i get in the javascript want to assign to PHP variable .So that i can use that in the query.
View Complete Forum Thread with Replies
Related Forum Messages:
Assign Variable Name As Variable
I want to be able to create a foreach loop that will go through all the intended POST variables and then assign it as a standard variable. For example, I want to have $username = $_POST['username'] without even knowing username exists in the context of the foreach loop. Code:
View Replies !
Assign Value To Variable
Is there any way I can use a function to create a variable and assign a value to it? I have a Perl script that returns some LDAP information: sn=Shore givenname=Mike logintime=20041008153445Z logindisabled=FALSE Instead of parsing this text and assigning the values, I was wondering if a function exists where I can pass a variable name and a value, and the variable would be created. ie. somefunc("sn", "Shore") Would create the variable $sn and assign the value "Shore" to it.
View Replies !
Assign To Variable
I am trying to take data from the database and assign it to a variable but i'm not sure how this is the code ive been trying $sql = "SELECT Name FROM Names WHERE Name = 'Peter'"; while($row = @mysql_fetch_array($sql)) { $var == $row['Name']; }
View Replies !
Is It Possible To Assign A Whole Function Or Block To A Variable ???
Is it possible to assign a whole function or block to a variable ??? eg. <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre> <? if (db_num_rows($qid_p) == 0) { ?> <li>No <? } ?> <? while ($prod = db_fetch_object($qid_p)) { ?> <p><b><a href="product_details.php?id=<?=$prod->id?>"><? pv($prod->name) ?></a></b> <br><? pv($prod->description) ?> <br>$<? pv($prod->price) ?> <br>[<a href="cart_add.php?id=<?=$prod->id?>">+ Add to Cart</a>] <? } ?> How to assign this code to a unique variable ???
View Replies !
Assign Function Output To Variable??
I've found some references to this topic at : http://forums.devshed.com/showthrea...ion+to+variable but it does not seem to be working for me. here's a snippet... <? PHP function listPeople ($getArray) { foreach ( $getArray as $val ) { echo "$val, "; } } $foo = listPeople($splitDirector); ?> The function works, and as you can see i'm simply trying to assign the output of the function to $foo. But instead, the output is written to the page where I assign it... like a print or echo statement, and the variable $foo is empty.
View Replies !
Ways To Assign A Value To A Session Variable.
I am wandering which way to assign a value to a session variable exist. Which of the following examples will work. Example #1: session_start(); session_register("ex"); $ex = 2.0; Example #2: In first.php: session_start(); session_register("ex"); In second.php: $ex = 2.0; Example #3: In first.php: session_start();...
View Replies !
Assign Variable From Database Field
Is there a way to assign a variable from a database field? I'm thinking along the lines of $make = $row_rsList['make']; $model = $row_rsList['model']; then they'll switch out based on my SQL WHERE statement. This valid syntax?
View Replies !
Assign Userid To A Session Variable
When a user logs into my system, i assign their userid to a session variable [php] $_SESSION['userid'] = $myrow[0]; [php] and then a user logs out, i do the following [php] $_SESSION['userid'] = '' session_write_close(); [php] so, when a user clicks on a link to a page they should only see when logged in, i do the following test [php] if (isset($_SESSION['userid'])) { header('Location: members.php3'); } [php] but the logout does not seem to work for some reason? userid still seems to be set after running the logout script, any ideas? am i doing something silly?
View Replies !
Assign A New Value To A Variable Passed From An Html Form
I'm trying to assign a new value to a variable passed from an html form to a php3 script. I'm using an if statement to evaluate variable 3 to see if it is equal to a specific string, if it is I'm reassigning variable 2 to be variable2+variable 3. if ($question3!="select days") { $question2=$question2+$question3; } This is the statement. It keeps giving me a parse error and I can't seem to find the right documentation to show me how to combine two string variables.
View Replies !
Multi-Dimensional Arrays - Assign Variable
It's a simple question, but I'm just not getting it. I have two files: <?php $precinct = array ( array ( number=>2324, centerlat=>-122.31705665588379, centerlong=>47.710367959402525, etc... <?php include ("precinctdata.php"); $filename = $_GET['id']; $number = $precinct[filename-1][number]; etc... I want to assign the value of "2324" to the variable $number. I've done this with arrays that start with number=>1, 2, 3, etc., but not successfully with specific values. What am I missing?
View Replies !
Assign MySQL Function Result To PHP Variable
I know to use: mysql_fetch_row($result) to convert a row from a SQL query result set into an array for use with PHP. but in the case of SQL queries that return one value, such as calls to MySQL functions, is there another PHP mysql api function I should use. For example, right now I use a "workaround" technique from PHPBuilder: $result=mysql_query("SELECT COUNT(*) FROM tablename"); list($numrows)=mysql_fetch_row($result); Rather than using this "workaround" code is there a way to simply assign the result of the MySQL function query to a variable. $result=mysql_query("SELECT COUNT(*) FROM tablename"); $numrows=mysteryfunction($result);
View Replies !
Assign Variable To A Block Of Html Code
Is it possible to assign variable to a block of html code? Something like this : $myblokvar = "<table width="487" border="0" cellspacing="0" cellpadding="0"> <tr> <td><table width="487" border="0" cellspacing="0" cellpadding="0"> <tr> <td><img src="images/bartitle_login.gif " alt="Login" width="475"...
View Replies !
Including A Variable In A Variable Before The First Variable Is Defined.
Is there any way to do this? $date = getdate(); $day = $date['mday']; $var = 'Hello have a ' . $var2 . 'day'.; if ($day == 7){ $var2 = 'bad' echo $var; } if ($day == 8){ $var2 = 'good' echo $var; } So that if it is the 7th, it would give "Hello have a bad day.", and if it is the 8th it would give "Hello have a good day."? All that I've tried doesn't work, because it doesn't seem I can define $var2 after it is stated in $var even though it is not echoed until after.
View Replies !
Loop Through Array And Create Variable Session Variable Names
As part of my user authentication class I've written a method that sets session variables. I pass an array to the function by reference which contains elements populated with information from the users table in the DB (name, street, country etc) At the moment the function looks like this: /* Set the session variables for easy access to user data */ function _setSessionData(&$userData) { $_SESSION['loggedOn'] = true; // Logged on $_SESSION['userID'] = $userData['UserID']; $_SESSION['username'] = $userData['UserName']; $_SESSION['password'] = $userData['Password']; $_SESSION['firstName'] = $userData['FirstName']; $_SESSION['surname'] = $userData['Surname']; $_SESSION['email'] = $userData['Email']; $_SESSION['street'] = $userData['Street']; $_SESSION['city'] = $userData['City']; return true; } What I'm wondering is if it is possible to loop through the $userData array, and dynamically name and populate the session variables rather than listing them all and assigning like I have?
View Replies !
What? Assigning A Session Variable Also Assigns The Local Variable?
Alright, In the following code, I expect the printed result to be: DEBUG: frank's last name is burns. Instead, what I get is: DEBUG: frank's last name is burns. Here is the code: $frank = "burns"; $_SESSION['frank'] = "black"; echo "DEBUG: frank's last name is is $frank"; What is coming into play here? I thought of register_globals but I thought that only dealt with GET, POST, REQUEST, etc.
View Replies !
Passing Multiple Variable Errors...last Variable Vanishes.
I have been trying to figure this one out for a few days now and it is starting to drive me mad. I'm sure this is something simple that I have done wrong but I can't for the life of me figure out what is wrong here. Some background. I decided I needed to learn PHP, I really enjoy it but keep getting stuck on things like this due to my lack of knowledge. So I set myself a challenge to write a PHP CMS system using PHP, mySQL, XHTML and CSS. All was going fine (all be it rather slowly) until I tried to write the page to edit articles in the CMS. I have the 'ID', 'title', 'venue' and 'article' stored in the database fine. I can pull entries out and display them fine. I now want to edit them using a browser. So I thought I would use the same form I used to add mySQL entries and change ti so that it loads in the article into the form fields depending on the id. (This is chosen through a link saying 'edit). Code:
View Replies !
How To Make The Mail Script Print The Name Of The Variable Before The Variable.
I have my mail script working. It sends correctly to the box specified, all data is correctly passed both in the email and in the sql db. My question is about how to make the mail script print the name of the variable before the variable. Joe Blow joe@blow.com I want it to look like: Name: Joe Blow Email: joe@blow.com I am not sure how to do this, and the little things I have tried just break my script. Can anyone point me in the right direction.........
View Replies !
$_GET Variable - Call The Variable Through The Include File
I'm using an include with a variable url. I'm trying to call the variable through the include file but it's giving me this error: Warning: include(message.php?word=hello) [function.include]: failed to open stream: Invalid argument in C:AppServwwwdirectory_here.php on line 281 PHP Code: // index.php <?php include ('message.php?word=hello'); ?> //message.php <?php echo $_GET['word']; ?>
View Replies !
Extract Variable From Database, Then Output That Variable.
I have this strange problem (and probably also a strange question). Let's say you set a variable $blah. The variable has 'test' as content. When I write the variable ($blah) to a database (and not the content of the variable 'test') and I want to output the variable again, I get $blah as output. And not 'test'. PHP Code:
View Replies !
Changing Variable Folder Names To Php Variable
Let me just show you quickly what I mean: The site url: http://www.nothing.com/vr/ will then redirect to http://www.nothing.com/index.php?sec=vr I'm just wondering if this is possible. The folder after the domain isn't an actual folder, but rather a pseudo one, which is then used in a varible. Another example: http://www.nothing.com/test/ -> http://www.nothing.com/index.php?sec=45&desc=test The "folder" has to be variable and so cannot be an actual folder.
View Replies !
Session Variable Becoming Linked To Post Variable
Basically i have a user id stored in session variable eg user_id =1. I have a simple forum that i created myself that inserts this session variable into the db with the persons entry. eg insert into forum value (session[user_id],'$_post['content']); This is all working fine until i go to edit this post from say the moderator account. I set the user_id for the "replace into db" initially to my session value unless i have selected to edit someone elses post, then i set it to the value submited back from the <form action=self> i get as far as selecting the contents from db only for the session variable holding my id to change to the value of the user_id selected from the db. Code:
View Replies !
Variable Not Working - Cannot Get The Cookie Variable Data.
my php script is working fine. In the afternoon, the scripts cannot function. It something to do with the variables. I using the print function <?php print $name ?> The variable is not able to capture from the url. for example www.xyzabac.com/?name=newbie. With the print function it should print out the variable data newbie, but it appear to be blank. This problem also appear in my form script. the data I got is blank. I also cannot get the cookie variable data.
View Replies !
Array Question - First Letter Of The Variable As A Variable?
I have been going through arrays and have a multidemensional array. When I want to print everything to the screen this is the code I used. To print the array values I used $a from $arrayvals, does php always take the first letter of the variable and use it as a variable? For the key I used $k and for the values I used $v, are these set in stone variables, or can you use any variable name you want for them? $arrayvals = array( array( "name" => "Taylor", "age" => "26", "occupation" => "Supernurse", ), array( "name" => "Rachel", "age" => "25", "occupation" => "Supernurse", ) ); echo $arrayvals[$a>0]['name']; foreach ($arrayvals as $a) { while (list($k, $v) = each ($a)) { echo "$k ... $v <br/>"; } }
View Replies !
How To Refer From One Variable To Hidden Variable?
I have started with my php source code shown below, and how can I refer from one var to hidden var? ---------------------------------------------------------------------------- if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO users (UserID, UserName, Password) VALUES (%s, %s, %s)", GetSQLValueString($_POST['UserID'], "int"), GetSQLValueString($_POST['UserName'], "text"), GetSQLValueString($_POST['Password'], "text")); mysql_select_db($database_SHHConnection, $SHHConnection); $Result1 = mysql_query($insertSQL, $SHHConnection) or die(mysql_error()); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO holidaymaker (HMID, Name, Status) VALUES (%s, %s, %s)", GetSQLValueString($_POST['HMID'], "int"), GetSQLValueString($_POST['Name'], "text"), GetSQLValueString($_POST['Status'], "text")); mysql_select_db($database_SHHConnection, $SHHConnection); $Result1 = mysql_query($insertSQL, $SHHConnection) or die(mysql_error()); } <input type="hidden" name="UserID" value=""> <input type="hidden" name="HMID" value= ""> ---------------------------------------------------------------------------- The "UserID" is generated by MySql with auto_increment.[color=blue] >UserID int(4) auto_increment primary key,[/color] Assume that I want to add new user and the value for UserID is 5 (after auto increment). Then, I want HMID refer to UserID, the value of HMID is also 5, thats mean HMID = UserID, how can I do that? What is the command?
View Replies !
Variable Variable Array Indexes
I am converting my script to run with globals off, this is for image uploads before I used to store the data in a variable variable ${"image".$i} with $i coming from a for loop. How do I convert this to work with $_REQUEST ${"_REQUEST['image".$i."']"} this doesn't want to know and as I see it that is the logical conversion, I have searched the forums but haven't come up with this yet.
View Replies !
SQL SELECT Using Variable Unless Variable Is Empty
Iv got a form where users input details that are then used as search criteria and it all works fine as long as all the details are enterd. But if a variable is empty then this blank space is used as search criteria with doesnt match any records and thus creates no results. Code:
View Replies !
Turning A Javascript Variable Into A Php Variable.
I'm currently having difficulties turning a javascript variable into a php variable. This is what i have so far: Code: function addCustomFields(){ var ee = document.getElementById('field_num').value; alert(ee); document.getElementById('field_list').style.display='block' } What do i have to add to declare a php variable so, for instance, i could call it furhter down the page like so: Code: <? echo $ee; ?> ...
View Replies !
Javascript Variable Posted To Variable
I wish to send a javascript variable, the website visitors time zone, to a PHP page, by way of a HIDDEN form submission (using the POST method). BUT I do NOT want to send this javascript variable to a different page - but to the SAME page. Then to display it on this same page. I have been banging my head against the wall on this for quite while now. Would be really grateful if someone could help me out. Below is my best stab at the coding - it is not working. I realise that the problem is probably related to my not refreshing the page in the right place. Code:
View Replies !
How Do I Match A Variable Against A Variable In A Loop?
Both recordsets pull from table "users" and is in a loop <? if ($row_users['username'] == $row_team_leads['username']) { echo ?> Now, the loop works for grabbing each $row_users['username'], but it obviously only grabs the first $row_team_leads['username'] to do the comparison. How do I make an internal loop to compare each $row_users['username'] against ALL $row_team_leads['username'] ? I get: user1 == team_lead1 user2 == team_lead1 user3 == team_lead1 user4 == team_lead1 user5 == team_lead1
View Replies !
Variable In A Variable 'refreshing' $url Once $ref Has Been Declared
I am sure there must be a simple way of doing what I want to do, but I can't find it! I would like to hold a url in a variable. The url contains another variable - e.g.: $url = '/a_page_name/' . $ref . '/'; My problem is that $ref is declared (via a MySQL query) after $url is declared. Is there a way of 'refreshing' $url once $ref has been declared, so that I only need to declare $url once in my header include file which is included at the beginning of all my pages? I know that I could place it in a separate file which could be included after the MySQL query, but I would rather avoid that if possible.
View Replies !
Variable Within A Variable Problem ...
i did some searching on these forums .. and tried the 'eval' solution with no success ... here is my problem .. i have a form post that submits to the same page .. then displays a table of the resulting data .. all that works great .. however ... i also need to include a link to a specific pdf file for each record .. i need to do a 'file_exists' to make sure that file is present ... if it is not .. i wat to display "not available" .. i know .. i know .. a simple solution would be to put the links directly in the sql .. but i dont want to do that ... i need to keep the files accesible through the intranet network .. for updates and such .. (its much easier for the bossman just to do it the way he always has .. you know?) .. anyway here is my code .. note .. i have already declared $nidid in the code above through a $_post ... also .. i have tested and it works fine if i put the actual file name in instead of the variable ...
View Replies !
Java Variable Is A PHP Variable
I am trying to create a javascript variable that hold the value or a php variable. The PHP var comes from a database and holds html text. I can do all this correctly but the problem I have is that the html text is multiple lines of code. The JavaScript Variable cannot handle that because the text needs to be all on one line, and since the text is dynamic adding end line code to the JS var is not good. I am not very knowledgeable the JS syntax but I can understand anything you throw at me. Here's what I have: var caltext=new Array() //Set submenu contents. Expand as needed. For each content, make sure everything exists on ONE LINE. Otherwise, there will be JS errors. caltext[1]='<?php echo $CalendarText[1];?>' caltext[2]='<?php echo $CalendarText[2];?>' caltext[3]='<?php echo $CalendarText[3];?>' This code creates text for the calendarday that I have set on an onClick event. This all work ideally. but this is the out I get to the browser:
View Replies !
Using A Variable Name To Make A New Variable?
Is this possible? Say I have a function, which excepts a variable in its definition... function example($var)....etc Now say I want to add _error on to the end of whatever variable I supply and use this as a new variable name. How could I do this?
View Replies !
Making A Variable From A Variable
I've got a class for producing a tab style look in html, everything is working, but I want to be able to pass a variable to the class and what the contents of the variable made into another variable for the class?!?! PHP Code:
View Replies !
Part Of Variable Name Is Other Variable
I'm writing a portion of a size that allows users to custom configure a product. One of our categories is "Video," and we give users a choice of including up to 8 diffent video devices. Because (a) these 8 menus are all the same and (b) we may change the number in the future when new hardware allows us to support more, I wanted to generate the menus using a while loop. Code:
View Replies !
Variable POST Variable
I'm using a class discussed in one of the DevShed tutorials "How to build an extensible form validator class". However, I need to modify one of the private member functions. PHP Code:
View Replies !
Finding A Variable Within A Variable
Is there a way to find a variable within a variable between two spots? Not exactly KNOWN spots... but imbetween two chars like: Code: $variable = "this is junk<but anything here is good>but this is junk again, but i'll need this later..." Is there a way to split that into three seperate variables, the first being before < and the seccond imbetween < and > and the third after >?
View Replies !
|