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.





Fetch Array - Create A $_SESSION Variable


I am writing a contact management php page. In the page I use mysql_fetch_array() to show the search results. If the user searchs by first name, there are times when multiple entries come up. Once the data is displayed on the screen the user has the option to edit, or delete this entry in the database. So on this one screen it shows all the search results.

If the user clicks on edit or delete, I then create a $_SESSION variable to bring this information to the edit or delete page. However this variable only gets created for the first entry when I do the mysql_fetch_array(). If I choose any entry after the first, it brings over the first entries information. How would I create a variable to bring this over to another page to edit or delete each specific contact. Is there a better way to do this?




View Complete Forum Thread with Replies

Related Forum Messages:
Weird Warning: Db2_fetch_array() [function.db2-fetch-array]: Fetch Failure
I've written a class Cars that is a holder class for <code>Car</code> and it's designed to fetch Car records from  out DB2 database. And it works fine until I return the $result to the calling function.

I can use my $result to print html table but only inside the getAll method.
When the $result is returned to the calling function the $result source is no more working  properly as expected by me though the resource id stays the same. Code:

View Replies !
Need To Fetch The Minimal Value Of The Items In The Array And Fetch The Key
function func_select_min_id($type_id_array){
foreach ($type_id_array as $type_id)
$item_query = 'SELECT * FROM prefs'." WHERE id='".mysql_real_escape_string($type_id)."'";
$item_result = mysql_query($item_query) or die ("Error doing query for this item ");
$item_row = mysql_fetch_array($item_result);
$rewards[] = ($item_row['paid']*$item_row['paid2']);
}
}

what this function does isnt that hard, I pass it an array of possible id's, which are basically mysql field id nr's and it looks up the concerning row, fetches 2 values and multiplies the 2, then the result is stuffed in a new array . My problem is I need to fetch the minimal value of the items in the array and fetch the key (so I need to re-establish which key actually corresponds to the product of the 2 values) .

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 !
Create An Array From Variable Seperating The Values By Comma?
I have a variable with the following values...

$variable = "3,6,9,12";

How would I create an array from this variable seperating the values by comma?

$array = array($variable);

Above doesnt work, it doesnt split the array in seperate values, it thinks "3,6,9,12" is one value?

View Replies !
Fetch Array
I have designed a debit-system database with a PHP frontend. The amounts need to be updated on a monthly basis. now i have 10 clients in the system. i can get all the fields and display them, but next to that, i need to insert a field where we can enter an amount per client and after all the new amounts have been filled in, i need to update the database with those amounts entered.
I know that by using html forms to enter the info, i can submit the info and do a update statement but the problem is, is that i need to dynamically add the field to update the amount according to the amount of results resturned from the database.

View Replies !
Fetch Variable From Another Domain Fsockopen Or CURL ?
I have a script that needs to check the 'mother site' for version information. The site contains an updates.php page that simply contains one variable $current = 1;

I initially tried to simple add this page as an include but found it would not work. I have been having a look around and it seems that I have two options. fsockopen or cURL.

I know nothing about cURL and have never used fsockopen (we are off to a good start aren't we :rolleyes: ) So before I take a hike up the learning curve I just thought I would get some advice on what would be the best option. The server the update.php page is on has cURL enabled. Code:

View Replies !
If Fetch Array Is Empty ?
I'm doing a fetch_array and I would like to display a "no records
found" message to screen. For some reason this is not working:

here's my Postgres SQL as proof:
surveys=# select othermore from table where othermore <> ''
othermore
-----------
(0 rows)

Then I have:
$result = pg_query($conn, "select othermore from table where
othermore <> ''");
while ($row = pg_fetch_array($result)) {
if (!$result) {
echo "no records<br>
";
} else {
echo "$row[0]<br>";
}
}

Strnage ? Can someone shed some light on what UI am doing wrong ?

View Replies !
Fetch Array Not Working
I am trying to post a detail message and say who the message was posted by. (the owner of the message) but it doesnt work quite right it says posted by the word "ARRAY". Some reason its not getting the name from the database.Can someone tell me why this is?

here is my code..

$get_owner_sql = "SELECT post_owner FROM forum_posts WHERE topic_id = '".$_GET["topic_id"]."'";
$get_owner = mysqli_query($mysqli,$get_owner_sql);
$post_owner = mysqli_fetch_array($get_owner);

View Replies !
How To Fetch Result Set As An Array
I use $result_set = mysql_query($query) to get a set of rows, and then I can use mysql_fetch_array($result_set)to access each value of column in a row, but each element inside is a column value of one row.

I want to get the result as an array from $result_set so that each element of array is an ENTIRE row, so I can add or remove elements inside. Is there such function?

View Replies !
Displaying All Data From Fetch Array
I'm having a problem displaying more then 1 result from a mysql_fetch_array statement in my php application.....

View Replies !
Mysql Joints And Fetch Array
i use joints in my query for example.  $query = "SELECT a.id, b.name FROM xxx AS a, yyy AS b WHERE a.id=b.id" and execute this query and use:

$res = mysql_fetch_array($query);

now.... how do i get the value..

is it
         $val = $res['a.id']

or

   $val = $res['id']

View Replies !
$_SESSION Vs. $variable
What am I doing wrong?

I set the variable co_name on the first page with an <input.... > and
session_start() at the top of both pages.

Clicking on a link that takes me to the second page:

Script on the second page.

echo $_SESSION['co_name']; Does not display
value of co_name
echo "Variable name co_name = ".$co_name; Displays value of co_name

One book suggested using echo {$_SESSION['co_name']}; Does not run.

Server is Apache2 Triad

View Replies !
How Do I Set A $_SESSION Variable
This is page is called to delete a row on a table using form input. I
set a session variable based on the result of mysql_query and want to
pass it back to the caller like this.

if (mysql_query($deleteSQL,$emailmanager) &&
mysql_affected_rows()>0) {
$_SESSION["mysql_query_result"] = "Your email address has been
successfully removed";
}else {
$_SESSION["mysql_query_result"] = "Your email address was not
found. Please try again";
}

.....

Here is the return code (generated by Dreamweaver) -

header(sprintf("Location: %s", "http://".$_SERVER['HTTP_HOST'].
$deleteGoTo));

How do I return the session variable to the caller? The $_SESSION
array does not exist on return to the caller. I check it using this
print code -

while ($var = each($_SESSION)) {
printf ("Session key <b>%s</bhas the value of: <b>%s</b><br>",
$var['key'], $var['value']);
}

View Replies !
Use $_SESSION['variable'];
this is going to sound really dumb but how to you set a session variable, i know you can use $_SESSION['variable'];, and i have read about session_register and session_unregister my problem is that at present i am using $_SESSION['variable'];

but i dont know how to clear/destroy this because when a Customer enters the website they can login or enter as a guest and if they enter as a guest they can login later, the only problem is when i go to the login later the $_SESSION['variable']; is registered as Guest still so i need to clear this and then reassign them with their customer number.

View Replies !
$_SESSION Variable Not Being Set
The problem I am having is with a cookied login system that I have created. When someone comes to the first page of the site, I call a method from my login class that validates a user via the information stored in a cookie and returns true if authenticated and false otherwise.

My problem lies in this: the cookie authentication is returning true and I then set a $_SESSION variable equal to the user's login id. The next step is a simple header() redirect to the home page. All works except for the $_SESSION variable is not set when the home page loads up. I can't figure this one out. Code:

View Replies !
$_SESSION Variable
I have tried to understand and read tutorials about accessing the session variables and I can't figure this out. Here is the code:

session_start();
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', FALSE);
header('Pragma: no-cache');

$user_id = $_SESSION['is_admin'];
print "<p>session var: ";print $user_id;print "<p>session var: <p>";
print_r($_SESSION);

here is the result:

session var:

session var:

Array ( [SESSION] => Array ( [user_id] => 8 [customer_id] => [is_admin] => 1 [first_name] => John [last_name] => Poppe [allow_customize] => 0 ) [enrollment_customer_id] => 9 [enrollment_user_id] => 116 )

$_SESSION['is_admin'] contains a value of 1 when I display the $_SESSION array, but when I try to get the value from the session variable I get nothing,

View Replies !
ODBC: Fetch Results As Associative Array
Will PHP fetch the results of a query using ODBC as an associative array? I know that MySQL does that, but I couldn't find it for ODBC connections.

View Replies !
MySQL Fetch A Number And Then Search Through That Array
Basically I have a very long array of integers. What I want to do is have MySQL fetch a number and then search through that array stoping at a number which is bigger than the number fetched then reporting the number it is bigger than and the number it is smaller than.

PS: Also, would there be a way to do this for every value in an array. IE have an array of column names and then for every column name get the value and pan through the array.

PSS: In addition after all that is done could it report the position in the array of the last value it was bigger than?

View Replies !
Which Fetch Is The Fastest Mysql_fetch_ Array,assoc Or Another?
I think the title says it, but I'm wondering if i'm only using an associative key should i just use assoc or is the speed so minimal it don't matter?

View Replies !
Mysql Fetch Array - Image Display If Available
I am using a HTML search form to give me the following result.  I can get everything to work, even get it to display images that are associated with particular search term, but can't figure out how to keep it from displaying that annoying little "There's not image here image" that explorer shows, the one with box and red "x". 

I know that an if statement would do the trick, but I can't do "if's" inside of the "echo" is it possible to accomplish this?  How? Code:

View Replies !
Using $_SESSION Variable For Different .php Files
Hi all, still working on getting my page authorization to work for logged-in users:

login.php
// if successful user login
$_SESSION['authenticate'] = 1;
if (isset($_SESSION['authenticate'])) {
echo "<br>session variable is set and has the value:".$_SESSION['authenticate'];
}
echo "<script language="JavaScript">document.location.href='"."http://www.exammple/quiz.php"."'</script>";

This works correctly and prints the session variable has been set to one, then goes to quiz.php

quiz.php
<?php
SESSION_START(); // tried with this line of code, and also ommiting it
if (isset($_SESSION['authenticate'])) {
echo "<br>session variable is set and has the value:".$_SESSION['authenticate'];
}
if (isset($_SESSION['authenticate'])) {
// display some html
}
else
{
echo "<script language="JavaScript">document.location.href='"."http://www.exammple/quiz.php"."'</script>";
}
?>

This does not print that the session variable has value 1. Am I calling/linking this properly, why does session variable loose its value...

View Replies !
Access To The $_SESSION Variable
I got a problem to access the $_SESSION variable in my script.

I wrote some login code: if the user logs in with his name and password
a user object is stored in the $_SESSION variable.

This all works fine , i can correctly read from that variable later on.

I have an old version of my site under a domain name and the new site
under another
domain name.
I wanted to link the domain name of the old site to the new one, but i
ain't got the data of that domain name (user name and password) so i
can't directly link it to the new site.

The 2 versions of the sites are also on different webspaces.

So i created a new index page on the old site. This page has a simple
frame in it wich loads the index of the new site, so far no problem,
but when i try to login it seems as if the $_SESSION variable is never
used.

Is this possible, and does anyone have an explication for this or a
solution?

View Replies !
$_SESSION Variable Not Carrying
I am trying to do some simple session stuff. However it does not seem
as though the session variable is being created for my site. I am
running the latest version of PHP and apache that I installed as part
of WAMP. Machine is XP SP2.

Basically I am trying to do something simple such as:

<?php

// initialize a session
session_start();

// increment a session counter
$_SESSION['counter']++;

// print value
echo "You have viewed this page " . $_SESSION['counter'] . " times";

?>

However my counter does not increment. I can also not see where any
sort of cookie has been created within IE, although firefox shows the
following:

Name: PHPSESSID
Content: 4s0n98f1s7jea6kg11psi4ckd3
Host: 10.0.0.15
Path: /
Send for: Any type of connection
Expires: at end of session

I am not sure about the Path: variable though. The address for my site
is 10.0.0.15/recipe

physical is C:wampwww
ecipe

Here are some of the contents of my php.ini file:

[Session]
session.save_handler = files

session.save_path = "C:Windows emp "

session.use_cookies = 1

session.name = PHPSESSID

session.auto_start = 0

session.cookie_lifetime = 0

session.cookie_path = /

session.cookie_domain =

View Replies !
Session Variable - $_SESSION['num']
I have following problem:
I try to retrieve images from mysql and show it.
I retrieve them in loop using getData.php.
getData.php uses session variable ($_SESSION['num']) to get image.

However $_SESSION['num'] seems to be always 0.
why?

//showAll.php
<?php
session_start();
$num=0;
session_register('num');
?>
<html>
<head><title>Show data from SQL Database</title></head>
<body>

<?php
MYSQL_CONNECT("localhost","root","pw");
mysql_select_db("database");
$sql = "SELECT count(id) FROM store;";
$result = MYSQL_QUERY($sql);
$count = MYSQL_RESULT($result,0,"count(id)");

//-------------------------------------------------------------------
//here is loop where $_SESSION['num'] is set and getData.php called

while($count >1) {
$_SESSION['num']=$count--;
echo $_SESSION['num'];
?>
<IMG SRC="getData.php">
<?php
}
//-------------------------------------------------------------------
?>
</body>
</html>

//-------------------------------------------------------------------

//getData.php
<?php
session_start();
if(isset($_SESSION['num'])) {

@MYSQL_CONNECT("localhost","root","pw");

@mysql_select_db("database");

$num=$_SESSION['num'];
$query = "select FileData,filetype from store where id=$num";
$result = @MYSQL_QUERY($query);

$data = @MYSQL_RESULT($result,0,"FileData");
$type = @MYSQL_RESULT($result,0,"filetype");

Header( "Content-type: $type");
echo $data;
}
?>

View Replies !
$_GET Problem And $_SESSION Variable
I have some PHP code that acts as a file manager and allows users to upload files, create directories and rename those files or directories. The renaming of a file is where I'm having some difficulty. I can get the file to rename, however, the page keeps displaying the javascript popup window where a user enters the new name. PHP Code:

View Replies !
Pass $_session Variable To Function
I'm trying to pass a session variable thru a function and have the variable print out futher down the script. The variable should be echoed but it isn't unless the page is refreshed. I found a work around but it doesn't seem right.

My script is working with the way the code is, so my question is why do I have to call session_register() after $_SESSION to make the variable print without refreshing and if this is wrong what is the proper way of doing it? PHP Code:

View Replies !
$_SESSION Question - Use The Registred Variable
I've a file login.php that create a session, register a variable(myVar) and
call (include) another file login1.php in the server side.
I need to use the registred variable in the second file but
$_SESSION["myVar"] is empty.

here is a simplified example of my problem, the command echo
($_SESSION["myVar"]) isn't displaying any thing
login.php :
========
<?php
$myVar="test"
session_start();
session_register("myVar");

include("login1.php");
?>

login1.php :
=======
<?php
session_start();

echo ($_SESSION["myVar"]);
?>

View Replies !
If $_Post And $_Session Are Empty Set The Variable
I am trying to say if $_Post and $_Session are empty set the variable $dcparent to equal 1, but it doesn't like what I am doing. Any help would be greatly appreciated.

if(isset($_POST['dcparent'])) {
$dcparent = mysql_real_escape_string($_POST['dcparent']);
}

if(isset($_SESSION['dcparent'])) {
$dcparent = mysql_real_escape_string($_SESSION['dcparent']);
}

if(empty($_POST['dcparent']) && (empty($_SESSION['dcparent'])) {
$dcparent = 1;
}

View Replies !
Value In $_SESSION[user] Populate The Variable
I have text entered into MySQL, the text is something like: The user's name is $_SESSION[user]

I would like to select this data from the database and actually have the value in $_SESSION[user] populate the variable when it gets output to the screen.

So instead of outputing This user's name is $_SESSION[user], I would like it to output The user's name is treeleaf20.

View Replies !
Is There A Way To Insert A $_SESSION['id'] Variable Into A Database?
This does not work because of the need for 's. Is there a way to insert a $_SESSION['id'] variable into a database?

mysql_query("INSERT INTO master (id) Values('$_SESSION['id']' ) " ) ;

View Replies !
Undefined Variable: _SESSION In P1info.php On Line 30
I'm getting a little frustrated w/ PHP. I have the following sequence:

page 1 gets input from user, calls script 1
script 1 sets session variables from page 1 POST with:
$_SESSION['email'] = $_POST['EMAIL']
$_SESSION['link'] = [mysql link]
script 1 calls page 2
page 2 takes in more data and calls script 2
script 2 gets session variables set in script 1 but errors out with:

Notice: Undefined variable: _SESSION in p1info.php on line 30

View Replies !
$_SESSION Variable Not Storing With Captcha Script
I am currently using a simple captcha script and am using a PHP file to create the image and using session_start() and $_SESSION['securitycode'] to set the actual text when it generates. The problem is its not storing the session variable.

Any suggestions or reasons why a $_session variable would not 'stick'? Is there a setting somewhere? I created a much simpler session file to test and it worked as follows: ....

View Replies !
Global $_SESSION Variable Doesn't Work
I have installed EasyPHP on my computer for testing PHP-Scripts. I have also written a whole System and it works fine when I Upload it to the actual server where it should be. The problem is, on my local server..the global $_SESSION variable does not work! Which server (or PHP) settings should be changed for getting this Global variable to work??

View Replies !
$_SESSION Array
A small problem that has me kinda baffled. This is the situation:

I've set up a self-submitting form FORM.PHP. Once the inputs are
validated, the info gets put in SESSION variables and the script
redirects the user to a review form REVIEW.PHP which displays the info
the user has input and allows them to edit or submit. At the top of
that page, I have the following code:

--- start code ---

foreach ($_SESSION as $key=>$submission) {
if ( empty($submission) || ($submission == "") || (strlen($submission)
== 0) ) {
$DISPLAY[$key] = "&laquo; BLANK &raquo;";
}
else {
$DISPLAY[$key] = $submission;
}
}

extract($DISPLAY);

--- end code ---

The form then displays the info now extracted from the $DISPLAY array.

By creating a new array $DISPLAY for the $_SESSION variables, the idea
is that this page will indicate the optional fields where the user
didn't input data with the string, "BLANK", without changing data in
the $_SESSION array. At the bottom, there is an edit button which will
take a user back to the original form where the form will be
repopulated with the $_SESSION data.

The problem I'm having is that the blank $_SESSION variables are being
overwritten with the "BLANK" string that's only meant to appear in the
review form. Not a huge problem, but I can't figure out why it is
happening.

Any ideas? I've scoured my code. There's nothing that deliberately
overwrites info in the $_SESSION array on the review page. All I can
figure is it must have something to do with the way FOREACH operates.

View Replies !
Copying A Multidimensional Array To $_SESSION
Specifically, is it possible to copy a multidimensional array into the
$_SESSION array - ie a deep clone of all keys and data?

I naively assumed that

$_SESSION["myArray"'] = $myArray ;

would work but it doesn't appear to work. Is there a single function
or assignment I can use, or would I need to use a "foreach" at every
level?

View Replies !
Clearing/deleting $_SESSION Array?
I have a $_SESSION array in a nested loop that I need to clear for multiple passes and cannot seem to figure out how to this. I have read the manual on unset and such but there seems to be no clear technique that I can ascertain. PHP Code:

View Replies !
Limit On The Size Of An Array In $_SESSION?
I have an object in the session-data which contains a search-result list.
It might, at various times, contain 16,000 entries or more.

I seem to be noticing, however, that when the size of the result-list is
more than around 1,000 records ... the object simply does not get saved
into the $_SESSION data at all.

The PHP memory-limit is 30 megs. I never see any curious output in the
Apache logs, and the application does not fail. The trouble is simply that
when the search result is large, and the search-results page enters, it
finds that there is no search-result object in the session data. For a
smaller result set, and /identical/ code, the object is there.

View Replies !
Removing A Single Value From $_SESSION Array.
What I have here is three select boxes one for all the tables in the db, one listing the table columns in that table and a third to collect the table columns selected stored in a session called $_SESSION['collections'].  Up to this point all that works beautiful the session stores the selected collections.

But heres what I want to be able to do: I want to remove single values from the $_SESSION['collections'].  How do I do that? Code:

View Replies !
$_SESSION Array Not Taking It's Values
?php
session_start();
if(!isset($_SESSION)){
$_SESSION=array();
}
if (isset($_POST['scheck'])) {
foreach ($_POST as $key => $val) {
if(ereg('^a[0-9]+$',$key)){
$_SESSION['$key'] = $val; ...?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

here is the session data but everytime I check the session values the array allways stays empty.

View Replies !
$_SESSION Passes Vars BUT NOT ARRAY
NO ONE seems to have had the problem I'm having - and it doesn't make ANY sense.

I'm running php 4.3.3 on a local server; and 4.3.10 on my isp's web server. I've tested this on both with the same results.

all I fricking want to do is pass an array from 1 script to the next - sure sounds simple enough - right? Code:

View Replies !
Updating Values In A $_SESSION Array
I've been working on a webshop, and I've got most of the functionality up and running. One problem, however, that I don't seem to be able to solve is as follows.

My shopping cart is stored in $_SESSION['cart'] array. As I need to keep tabs on what items are ordered and their quantity I add elements like this: Code:

View Replies !
Create A New Variable Which Is An Hour And Fifteen Minutes After The 'time' Variable.
if i have a variable 'time', and I want to create a new variable which is an hour and fifteen minutes after the 'time' variable. how do i write that?

View Replies !
Array Merge Problem - $_SESSION Involvement
I have a form that I have built for submitting a long list of information from the user. If there is a problem that got missed by the javascript validation I would like to catch the error on the server-side with a function I have in the form handler script. Then when they have to go back to the form, it is populated with the information that they had already typed in without having to re-type it again.

The problem is I would think the best way to do this is to create a session variable for each of the fields in the $_POST array. Then on the form itself, use the value = '{$_SESSION['fieldname']}' to populate the fields when they hit the back button. I read that ARRAY_MERGE() does not work.

I am working on a system that we do not know exactly what is already in $_SESSION array (we are basically hacking an existing system) so we need to leave the $_SESSION array intact, but add in the $_POST array. How do I do this easily without spelling out each and every variable explicitly on the form and placing it into the session array?

View Replies !
Array Problem... - Store This List In $_SESSION['liste'];
the user selects 6 numbers in a list I have to store this list in $_SESSION['liste']; (I cant do it differently) the list is stored like that: 34-21-44-32-12-11 (cant do it differently either)

what I need to do is to explode the array, get rid of the - , sort the values in ascending order and send them to my table as a string. so in the end I should have: 111221323444

I tried using a variation of laserlight's script (given in a previous post) without success... hope that someone will have time to give me a hand again in telling me what I could change in saberlights script to make it work.

View Replies !
Pass The Current $_SESSION[] Array Variables To Secure Domain
I'm trying to pass the current $_SESSION[] array variables to my secure domain for payment details. I am attempting this via passing the SID via URL thus:

example1.php (Non-SSL)
<?
session_start(); // Start Session
$_SESSION['package']='Package1'
$SID = session_id();
echo $_SESSION['package'] ;
echo "<form action='https://secure.example.com/example2.php?SID=$SID' method='post'><input type='submit' value='Continue'></form>";
?> example2.php (SSL)
<?
session_start(); // Start Session
if (isset($_GET['SID'])) {
$_SESSION['session_id']=$_GET['SID'];
}
echo $_SESSION['package'] ;
?>

View Replies !
Trying To Compare Array Values To A Value, Then Create Boolean Array
I have an array that returns data like this (see array below) The array[0] contains all the votes for one story as well as information that pertains to that vote, and the array[1] contains vote information for another story. What I need to do is check is a user_id stored in a session, is in the array, and then create a boolean array from that.

For example, here I want to check if the user_id is featured in the first set of data, let's say my user_id is 74. Ok, so it is in the first set of data, so we set the boolean variable to true. Next I need to search the second data field for my user_id, 73. It is not featured here so the value in my array is set to 0.

I need an array that returns values either 1, for true, your user_id was found in the table, or false, for your user_id was not featured in the table. They need to be in order of the story too. I'm having trouble one comparing the two variables against eachother, since the array is very deep, and two, creating the array on the fly. Code:

View Replies !
Create Array From Members Of An Array Of Objects
I have the following situation:

$list[] is an array of MyElement objects.

MyElement has two members: MyElement->member1; MyElement->member2;

What I want is to get the following:

$newlist[] so that:

$newlist[0]=$list[0]->member2;
$newlist[1]=$list[1]->member2;
$newlist[2]=$list[2]->member2;
....

I need to do this using A SINGLE LINE OF CODE.
Is it possible? How to do this?

I tried with:

array_walk($list,create_function('$a,$b,$result',' $result[] =
$a->member2;'), &$result);

but I get the following error:

Warning: Call-time pass-by-reference has been deprecated - argument
passed by value; If you would like to pass it by reference, modify the
declaration of array_walk(). If you would like to enable call-time
pass-by-reference, you can set allow_call_time_pass_reference to true in
your INI file. However, future versions may not support this any longer.

View Replies !
Assigning A Multi-dimensional Array To & From A Session Variable Loses The Array
I have created a multidimensional array and then assigned that array to a session variable so that I can use it easily on another page.  However, when I go to the array later, there's never anything in it. Code:

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 !
Create A Variable Of A Stringname
How can I do this:

1) i have string $test="jeroen";
2) a want to create $jeroen = 0;

how can i do this?

$'$test' = 0 ; ? (i don't think this wil work

this is code where i need this:

$fotoarray[0]="bedrijfsleiderfoto";
$fotoarray[1]="logo";
$fotoarray[2]="foto1";
$fotoarray[3]="foto2";
$fotoarray[4]="foto3";
$fotoarray[5]="foto4";

for($i=0;$i<6;$i++)
{
if (isset($'$fotoarray[$i]'))
upload($'$fotoarray[$i]',$naam,$fotoarray[$i]);
}

View Replies !
Create Table From Variable
I need to know, how I can to do to create a table in PHP, taking de
name for this table from a form variable.

View Replies !
Create Variable From Loop
i have results echoed on a page. but i can't seem to create the variable in a loop;

for($i=0; $i<4; $i++){
$res[$i] ="what ever goes here $i";
}

and then

<? echo $res1 ?>
<? echo $res2 ?>
<? echo $res3 ?>

.... later in the html layout of the page... i thought it was somink like this ${'res'.$i}

View Replies !

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