Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





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 Complete Forum Thread with Replies

Related Forum Messages:
How To Assign Data In A Table Field To A Variable
what exactly do i do to only retrieve information from a table and assign it to a variable? I don't want to manipulate the data in any way, just display it on the page.

View Replies !
I Need To Compare Variable Against Database Field...
I have a variable coming into my script via a post operation. That variable ($fromFlash) is being sent to the script from a Flash movie and just contains a website URL. I have a MySQL database containing the names of organizations with their website addresses.

I need to compare my variable against that database, to see if there is a match for the website address contained in the variable; if there is a match, I need to pull the record and send the organization's name back to my Flash movie -- if there is no match, I need to send an error message. Code:

View Replies !
Can I Assign A Number To The Name Value In A Text Field?
I'm using a while loop to query products from a table to create an orderform. Works fine.
The products and descriptions "echo" on the page to create the orderform and a text field named "qty" for quantity ordered is written for each product in the table. 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 !
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 Replies !
How Can I Assign Output To A Variable?
I'm trying to send an email and would like to put the output of some of my script into the body of the email. Here's the part that needs to be executed: PHP Code:

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 !
Get A Page Title And Assign It To A Variable
Is there a command or a procedure to get a page title and assign it to a php variable.


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 Dynamic Dropdown To Variable?
Is it possible to assign a dynamic dropdown script to a $variable? Code:

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 !
Count The Number Of Matches And Assign A Variable For Each One
I've been trying to work out a problem but I'm having no luck. I have
field in my table for area and I need to count the number of matches
and assign a variable for each one.. this is what I have but it doesn't
work.. any ideas? Code:

View Replies !
XML: Assign A Variable To TransactionArray.Transaction.TransactionID Where User ID =?
I want to be able to find and assign a PHP variable to the Transaction ID where the UserID is a specified user though Ebays XML API. Code:

View Replies !
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 Variables To The Value Of The Post Variables Using The Field Names?
I’ve been using an older version of PHP up until recently. Using the older build I had 'register_long_arrays' on. However this depreciated some time ago and I want to start working with 'register_long_arrays' set to off.

My question is; if, for example you have a form with 25 fields is there a quick way assign variables to the value of the post variables using the field names? Code:

View Replies !
Variable Won't Go In To Db Field!
I have this script that gets the name of all jpegs in a directory then passes the name along with other information into a database.

With the exception of $image_name all variables are being passed correctly to a new record. However the field for $image_name is always blank even though $image_name echos the file name perfectl!

I've tried both text and varchar for the mySQL field type and neither works. Code:

View Replies !
Printing Field/variable
I have a script for clients to update their information directly, when they submit the new information is printed for them to see. If they use a single or double quote in the information entered - the / character appears before it. How can I make this not appear?

View Replies !
Variable In Form Field
I want to put a variable as the content of a hidden field. I realise that normally you would just open up a set of php tags and echo the variable in which I have done in the past, although I need the whole form in php tags as I have made the form a function in order to hide it with sessions when no body is logged in. This seems to be causing a problem as I can't get the content of the variable into the field its just echoing the actual statement in. Code:

View Replies !
Set Variable Name Use Field Name From Table
I have a query string that sets the value of Variables below:

if ($DB == "Departments") {
$tracking_id = $data22['tracking_id'];
$dept_name = $data22['dept_name'];}

simple and straight forward. Now I would like to set a loop that would set the variable name and value based on the field names in the table queried.

if ($DB == "Departments") {
$querystring = "Select * from ".$DB;
$result=mysql_query($querystring);
while(($field = mysql_fetch_field($result))) {
$field->name = $data22[$field->name];}}

can I set the variable name using the $field->name if so how? I have tried this code with no luck and no luck searching. This is a small example. I have queries with fifteen plus fields. This would also remove the need to modify this code if a field needs to be added to the table. And yes I have had to add fields to the tables.

View Replies !
Text Field Variable
I'm new trying to use php forms.  Trying to write what is typed into the text field to a file.  But its not working.  It makes the file, but the text field data is not written. Code:

View Replies !
How Can I Set A Variable To Mysql Field Value?
I want to set a variable to mysql field value, I know this code works upto print $info['username'] command but it's not working to set $username, as the echo $username is not displaying any information. Code:

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 !
Can I Set The Value Of A Text Input Field Using A Variable?
Is it possible to do something like this?:

<input type="text" maxlength="10" length="15"  value= some_string_returning_function($value)  />

I am trying to send a form back to the user for him/her to correct a field,
but i want the other fields (already validated) to still have what he had previously entered in them.

View Replies !
Setting The Value Of A Text Field Using The Value Of A Variable
i have a function which generates a unique number containing both letters and numbers (4 long), i have assigned the result of this function to a variable called $id.

i want the value of this variable to be the initial value of one my text fields on my html form, to do this i used Code:

View Replies !
Changing Stuff In A Form Field To A Variable
I want to be able to change stuff typed into some form fields into a value so I can upload to a mysql table, then have it displayed on another page. I'm just not sure how to transport the form text.

View Replies !
Importing A Field From MySQL Into A Variable In Flash?
I have a query that is giving me the field that I require from my database using PHP.
What is the best way to import this variable into flash? Can I echo the number out on the page and have Flash import it that way? Could I use the Load Variable command? code:

View Replies !
Passing PHP Variable Into An Html Text Field
I am working on a flatfile configuration program and I need to read a single record csv file into php and pre-load the values into html text boxes. I have the file reading part working with 6 variables $field1 through $field6. When I am done, I then save the form back to the same file. This allows a configuration file to be updated from the web.

View Replies !
Replace Empty MySQL Field Variable
I have the following MySQL query:

$usermood = mysql_query("SELECT * FROM `user_info` WHERE `user` = '$c[user]'");
while($row=mysql_fetch_array($usermood))

if (empty($usermood)) {

$mood = blank;

} else {

$mood = $row['mood'];
}

The query works, but my problem is in the "if/else" statement... What I wanted to do is to replace the variable $mood with the word "blank" if there's no data in the "mood" field. The "$mood = $row['mood'];" works fine and I'm able to display an image using the variable, but my problem is when there's nothing in the field, I get a broken link image.

View Replies !
Editing ID Field In Database.
I have come across a problem with some coding work that i am doing. My problem is the following: Presenters in the radio station, are shown in order of ID.

What i want to be able to do, is edit the order in which they are shown, by editing the ID. My problem, is that when i process the form the script has no way of telling what the field names are, as they are not pre defined, because i have put the code in a while loop, to get all of the DJ's names & id's out. Code:

View Replies !
Read The Id Field From My Database!
I have a databse set up, and I can read all of the other fields, but I cannot get any information out of the "Id" field. Here is the code:

View Replies !
To Retrive Field Name From Database
i have the form which has text box called hotel name and a button called "GO".. whn i insert the hotel name in d box and click on "GO" button, i need to select the exact match from database and display on the page.. Code:

View Replies !
Database/Field In A Row Question
I have a page that displays a table of addresses from a database and I want a user to be able to click on the address and that will bring them to a page with more information on that address. How do I do this?

I can write the SELECT statement for the page where the detailed information will be displayed but I’m stuck on how to make my address field bring me to the next page.

View Replies !
Adding 1 To Field In Database
I've been written a bit of php that basically adds 1 to a field called Votes in a database. there is no where else in the code that edits the fields

$query = "SELECT PID, Votes, Total FROM Pictures WHERE ((`Pictures`.`PID` = '$PID'))";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result))
{
$Total = $row['Total'] + $Rating;
$Votes = $row['Votes'] + 1;
}
$query = "UPDATE Pictures SET Total='$Total', Votes='$Votes' WHERE PID = '$PID'";
$result = mysql_query($query);

It works fine in firefox the problem is that when its run in Internet Explorer it sometimes adds 2 to the record Am i doing something stupid. I've searched for the answer and ive tried lots of other things but cant get it to work.

View Replies !
Pulling Field From Database
I'm looking to pull a paragraph into my page from MySQL. Within this paragraph are a few links written in the following form: http//www.phpbuilder.com. How can I make these links clickable on my page? Right now they are just plain text.

View Replies !
How To Create A Hidden Field Variable From An Echoed PHP Figure?
I have a PHP script on a shopping cart summary page that creates an invoice number and then echoes it to the page. This page, when submitted, will go to the shopping cart processor.

The echo portion of the script is working properly, it generates the number as intended.

My problem is that, not being very experienced in PHP, I want the invoice number not only echoed (which it is doing properly now), but also to populate a value in a hidden field that is submitted to the shopping cart processing page. My question is how do I populate the hidden field with the figure that is now being echoed in the script below?

The script that generates and echoes the invoice number is as follows:

<?php
echo "SA"; //department code
echo date ("mdy"); //date generator
// begin counter this reads figure from "count_file.txt"
if (file_exists('count_file.txt'))
{
$fil = fopen('count_file.txt', r);
$dat = fread($fil, filesize('count_file.txt'));
echo $dat+1;
fclose($fil);
$fil = fopen('count_file.txt', w);
fwrite($fil, $dat+1);
}
else
{
$fil = fopen('count_file.txt', w);
fwrite($fil, 1);
echo &#391;'
fclose($fil);
}
// end counter
?>

The hidden field is as follows:

<input name="Invoice_Num" type="hidden" id="Invoice_Num" value=" ">

I would like the value in the above to reflect the invoice number that is echoed by the above PHP script.

View Replies !
How To Pass Variable To Another Page Into A Hidden Field In The Form.
I have a script to tell whether a domain name is available or not. The code redirects to the php script and displays the results in a template file called "whois.html". Then on the page that displays the results, I want to have a link to go to the next page. I want to pass the variable that contains the selected domain name called $domain.$ext. I need to know how to pass that variable to another page into a hidden field in the form.

View Replies !
Modifying Database Using Primary Key Field?
Is there a problem with using the primary key as a definition of what to delete? I am using the following script: PHP Code:

View Replies !
Insert A New Field Into A Mysql Database?
what is the proper way to insert a new field into a mysql database? i want to insert a new id guildname and username? i mean doing through a php script?

View Replies !
Insert And Set The Value Of A Field Start_id In My Database
i need to do an insert and set the value of a field start_id in my database to the same value as the field text_id which is the auto incrementing field.

how is it possible to do this in one query ie set the value of the second field = the value of the first field or set the value of the second field = the number of rows + 1 of the table (same thing) any ideas??

View Replies !
Counting Field And Update Database
I was trying hard to alter an existing script ut I didn't succeed to... 

I have 2 databases:
- Categories (catid, shortname, description)
- Transactions (date, amount, balance, user)

in the categories I have 9 categories.

the script displays the categories as checkboxes to choose from. I want to add the following functionality:

If I select for example 3 categories, I would like to know how can I count the selected checkboxes and based on the count update the transactions database:

in another way:

if count=3 => add amount  x 3 to the transactions database so if a user select 4 categories I update the transaction database with $5 x 4 categories and then we will get a balance of $20 for the choosen categories.

View Replies !
Database Cookie Id Field Problem
I have a database and shopping cart, the items are selected by using the session_id in a cookie. So if you log out your cart stays intact.

 select * from  cart
         inner join household on cart.itemName = household.itemName
         where cart.cookieId = '" .   GetCartId() . "'");

GetCartId() runs at first to check if the cookie exists or not, if not create a new one.

But when the cookie has expired it writes another one which I have checked and it is a different session_id inside so in theory the last order in the database can now not be selected because the session_id that the SELECT statement uses has changed.

But it still appears in the cart. I have echoed out the GetCartId() and it is different from the database cookieId field so I have no idea how this is happening. The only way of getting rid of the last order is to delete it from the database.

View Replies !
Searching Part Of A Database Field?
What i have is a massive log file and ive tried extracting using Excel, Word etc but it doesnt work effectively.

say in one database field i have:

/index.php menu_id=1116 80 - 194.152.95.202 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322) 200 0 0 14775 526

I then need to extract and return just the menu_id=x and return x in a variable, any ideas how to go about this?

View Replies !
Search String In Database Field
Is it possible to search for a particular string within a database field,

for example string = 'Program Finished' field name = 'Output'

if so how?

View Replies !
Search Database For Two Words In A Field?
Is this possible? Say the table is :

ID string
01 apple orange pear
02 apple banana
03 orange banana mango pear

Code:

View Replies !
Database Field And Text Area
I need to use a text area in a form instead of an input field so a larger amount of text can be inserted. When I try to use this

value="<?php echo $row[databasefield];?>" like I do in my input fields
<input value="<?php echo $row[databasefield];?>" name="databasefield">

and try to use it in a text area field instead.

<textarea rows="5" cols="25" name="databasefield" value="<?php echo $row[databasefield];?>" ></textarea>

The database property won't appear in the form like it will with an input field. How do I adjust for the text area field to show the database info instead? Right now nothing is appearing in the text area field.

View Replies !
Return The Sum Of A Field In A Mysql Database Using PHP.
I'm trying to return the sum of a field in a mysql database using PHP.  For some reason the function doesn't want to return a value. It gives me a result resource message.  The following is the code that I'm using.

$query5 = "SELECT SUM(num) FROM bappurchased WHERE bapnumber='$data_key'";
$result5=mysql_query($query5);

$data_key is a variable that is carried over from a previous page and it holds a numerical value that corresponds to the rows that contain the field that I'm trying to sum. I'm trying to return the sum of these fields and use the value for further calculations on the same page.

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved