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




DOM XML - How To Append A Link Element As A Child


I'm trying to generate a RSS newsfeed using the DOM XML functions, but you
already know that if you read my previous post .

I'm able to create rss, channel and title elements but not a link element.
The following code sample doesn't generated
<link>http://www.websitetitle.com</link> but <link> like if the DOM XML
forgot to close the element :

<?php
$link_el = $dom_doc->create_element ('link');
$link_el = $channel_el->append_child ($link_el);
$link_el->set_content ('http://www.websitetitle.com');
?>

Then I got some crazy idea. I thought that maybe DOM XML was thinking the
link element I created was a specially element, not an enclosed one, like in
XHTML for example :

<link rel="stylesheet" type="text/css" href="styles.css" />

Crazy crazy because I don't see why DOM XML would handle my elements as HTML
elements... But then I tried with a meta tag, and guess what... It also
doesn't work ! It works with enclosed elements, tags, like title, head,
html, body or unknown ones like channel or item. But it doesn't work with
link, meta and input elements !

And I have no clue why it handles these elements as special elements...

Here is the full script :




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Append A Child Dynamically
i m new in both things php and in this group.
but i have some basic knowledge of php and DOM in php.

here is my problem,
i have one textfield for add a new main node (not main like:
<root><this_one></this_one></root>) in my php page and i m able to save
the xml file correct with this, and in the bottom of that i have one
new textfield for add new child in dynamically create node (which i
descibe above),and one combo box for show the all dynamically create
nodes.now i want that when user give the value in child textfield and
then select a root node for that child from combo box.i want to append
a child dynamically to root node.

but i m not able to do this. plz try to solve my prob...

Append To String
I've got 3 variables in a form: products[], ib, wl. products[] contains whichever values where checked from about 20 checkboxes, and the other two (ib, wl) are either "yes" or "no". The reason for this is that there is a limit of 4 products to order, except for ib/wl which don't count as part of the 4. Now, want the values to be sent by e-mail: "Products: ql, ba, wl".

I did [b]$prod = implode (",",$products);[b], and then I would like to append ", wl" to $prod IF the value is "yes" and also ", ib" if the value is "yes". How would I do that? Thanks!

Array Append
How may I programatically append and create the following predefined
array in PHP?

Although the example has all the data and the subsequent arraw
predifined I must create an array while iterating through the rows in an
RDBMS.

array(
array('name' => 'bob', 'phone' => óS-3425'),
array('name' => 'jim', 'phone' => óS-4364'),
array('name' => 'joe', 'phone' => óS-3422'),
array('name' => 'jerry', 'phone' => óS-4973'),
array('name' => 'fred', 'phone' => óS-3235')
)

Header Append Question
I am trying to avoid using frames when people click on my links section to see other sites outside of my site, but I don't want to have them leave in a new window. Sort of the way that yahoo shopping works where it can bring in other sites, like KMart, Jcrew etc. and have the yahoo header on top of them but all be in the same scrollable page. How is this done?

My problem thus far has been that if I put my header on let's say Kmart's site. The minute someone clicks a link in the kmart page I can't still have my header there, but Yahoo can?

Treemenu Append Automatically
Here i got a problem to append my treemenu file automatically. this mean that the user haven't need to click the main title of menu to display their subtitle(allow the user to done other funtions on it).

Loop Through And Append To String
The following code: for ($i = 0; $i < $varcount; $i = $i + 1) {echo "," . "$parts[$i]";}

Will output: ,$parts[0],$parts[1],$parts[2],$parts[3],$parts[4],$parts[5],$parts[6],$parts[7],$parts[8]
What is a good way to append or save the resulting output to a variable?

Append Two Textfields Into A Third One With A Space
i dont know if its a stupid question but im so new to php you can forgive  me
well the thing is i have 3 text fields

textfield1
textfield2
textfield3

I want to add textfield 1 with textfield 2 and display it in a hidden textfield3 with a space between the text.

Textfield1(Sam) + Textfield2(Yam) = Textfield3 (Sam Yam)

Append To A Temporary File?
Is it possible to append to a temporary file?

I'm iterating through a file and when a condition becomes true, I want to append the content to a temporary file.  I want to display the contents once the loop completes. If there's a better suggestion on how to go about this, please let me know.

Error Check Before Append To File.
I want to be able to append my httpd.conf file from a web browser to make adding virtual hosts a little easier. I've got a simple form that passes two variables. $virtualhost and $subdirectory.

what I want to be able to do is read the file and make sure that there is not already a domain name and subdirectory in the file. Code:

DOM Child Finding
Is there any faster/easier way of finding a child node of a certain
DOMNode object than doing something like

function getChildByTagname($curnode, $name)
{
foreach($curnode->childNodes as $node)
{
if($node->nodeName==$name)
{
return $node;
}
}
}

?

it seems fairly slow and cumbersome. i was thinking xpath, but i can
hardly imagine that to be a lot faster, with all the DOMXpath object
creation and all, though I didn't benchmark.

Check For XML Child
I need some help for checking for the following:

<?xml version="1.0" encoding="ISO-8859-1"?>
<error>
<err type="2">Invalid location provided.</err>
</error>

Heres my PHP code:

$hold = array();
$v_URL = "http://xoap.weather.com/weather/local/{$loc}?cc=*&prod=xoap&par={$par}&key={$key}";
$o_XML = new SimpleXMLElement(file_get_contents($v_URL));
$err = $o_XML->error;
if($err){
$fcity[0] = 'Check Your ZipCode'
$deg[0] = 'n/a'
$icon[0] = 'error'
}
else{
$hrm ="<FONT FACE="Symbol">°</FONT>F";
$city = $o_XML->loc->dnam;
$fcity = explode(',',$city);
$deg = $o_XML->cc->tmp; // Temperture
$icon = $o_XML->cc->icon; // Weather Icon
$lat = $o_XML->loc->lat; // Latitude of City
$lon = $o_XML->loc->lon; // Lonatitude of City
$vis = $o_XML->cc->vis; // The Visibilty
}
$hold[0] = $fcity;
$hold[1] = $deg;
$hold[2] = $icon;
// Output the Weather Array of $hold
return $hold;

Any ideas for checking for that? also heres a working zipcode xml output

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--This document is intended only for use by authorized licensees of The Weather Channel. Unauthorized use is prohibited. Copyright 1995-2005, The Weather Channel Interactive, Inc. All Rights Reserved.-->
<weather ver="2.0">
<head>
<locale>en_US</locale>
<form>MEDIUM</form>
<ut>F</ut>
<ud>mi</ud>
<us>mph</us>
<up>in</up>
<ur>in</ur>
</head>
<loc id="04537">
<dnam>Boothbay, ME (04537)</dnam>
<tm>10:10 AM</tm>
<lat>43.88</lat>
<lon>-69.63</lon>
<sunr>6:07 AM</sunr>
<suns>7:06 PM</suns>
<zone>-4</zone>
</loc>
<cc>
<lsup>9/6/07 9:45 AM EDT</lsup>
<obst>Boothbay Harbor, ME</obst>
<tmp>62</tmp>
<flik>62</flik>
<t>Mostly Cloudy</t>
<icon>28</icon>
<bar>
<r>30.34</r>
<d>steady</d>
</bar>
<wind>
<s>9</s>
<gust>N/A</gust>
<d>160</d>
<t>SSE</t>
</wind>
<hmid>95</hmid>
<vis>10.0</vis>
<uv>
<i>2</i>
<t>Low</t>
</uv>
<dewp>61</dewp>
<moon>
<icon>24</icon>
<t>Waning Crescent</t>
</moon>
</cc>
</weather>

I was trying to figure out how to check for <error></error>. but can't quite figure it out.

Children Of Child Node??
Is there any function or way to access the children of a child node using DOM???

I mean if i have the xml structure as:
<app>
<app_data>
<data name='method'><value>sum_dif</value></data>
<data name='val1'><value>123</value></data>
<data name='val2'><value>456</value></data>
<app_data> // child of child node
<data name='coool'><value>divo9</value></data>
<data name='sands'><value>007</value></data>
<data name='make'><value>bond</value></data>
</app_data>
</app_data>
</app>
How can I access the data in the child node <app_data>?

Child Construct Parent
I'm building out a OO based app in PHP 5 but I'm getting a little
confused on children contructing parents.

I have a parent that looks like this:
abstract Class State {
protected $database;
protected $user;
protected $output;
public function __construct($database,$user,$output) {
$this->database = $database;
$this->user = $user;
$this->output = $output;
}
}

And a child that looks like this:
Class Status extends State {
public function __construct($database,$user,$output) {
parent::__construct($database,$user,$output);
}
}

This seems to work OK. But I'm getting confused when thinking about
adding a new child who then has to contruct the parent again. Isn't
this getting away from the whole purpose of inheritence? It seems like
this is recreating the parent with every new child that come along.
Would it be possible to just have a single instance of the parent that
all children extended or am I missing the point here?

Child Object On Demand?
I have an application that suffers from my amateur coding
inefficiencies, and I am trying to clean a few things up. I have an
extremely database intensive object, which I have tried breaking into
smaller child objects to reduce database queries when they aren't
needed.

I currently have something that looks a bit like this:

class Object {
function Object() {
$this->attribute1 = dbQuery("foo");
$this->attribute2 = "bar";
$this->child = new SomeOtherObject($attribute1);
}
}

$foo = new Object();
if ($foo->attribute1 == "X") echo $foo->child->attributeA;

Because every page load does not require $foo->child to be populated,
is there a way to only establish the child object if it is referenced?
Where is a good place to read about dealing with child objects?

Fopen - Append Works, Write Fails (but File Is Truncated)
I'm trying to write to a file in the current directory - no remote
files. The subject says it all - I can add that both the directory
and the file is wordwritable. This happens on a (quite good) free
hoster in Norway which doesn't use safe mode, running PHP 5.1.6 as the
PHP info below shows ...

Test it at:
http://home.no.net/moldevbk/fopen-test/?mode=w (write - fails)
http://home.no.net/moldevbk/fopen-test/?mode=a (append - ok)
http://home.no.net/moldevbk/fopen-test/p.php - PHP info
http://home.no.net/moldevbk/fopen-test/fopen-test.phps - source code of test script.

I have searched the web and usenet, but not found this problem
mentioned before. I do realize that I can work around the problem by
truncating the file first and then appending to the empty file - but
that is ugly as ...

Parent Refreshed By Child Window
I wonder if I could refresh parent window in PHP when I close child. I know
that I can refresh but I need to keep entered data which I have in parent
window.

Display Child Records Only When Checkbox Is On
I have a list of nested arrays, that displays the parent, and then has the child records indented underneath. I want to be able to make a collapsible list, which I know how to do with regular data, but I'm having troubles getting the child records to display.

I can get regular text to show up when I click but not the child records. What I am currently doing is calling a javascript onClick that changes the span textContent property.

What would be the best way to handle the child records? Putting them in a function and calling it from the javascript by way of AJAX or something? Code:

Creating A Parent->child Tree
Does anyone know any good tutorials on creating a parent->child tree?

Ive looked through google but cant seem to find any?

An SQL Query To Insert One Child For Multiple Parents
Let's say we have two tables:

Table 1) Category [fields= categoryid,categoryname]
Table 2) Sub-Category[fields= subcategoryid,categoryid,subcategoryname]

Let's say:

There are 5 entries in Category Table and that are

1,Books
2)Games
3)Toys
4)Computers
5)Cars

now, if i want a subcategory of category "Cars", simply i add a subcategory in it with categoryid=5

thats no problem.

i want a MYSQL query that could allow me to add a subactegory for all those 5 categories in one Query.

so that query enters 5 new rows in table "subcategory"

where subcategoryid,subcategoryname remains same but categoryid is 1,2,3,4,5 respectively.

Parsing XML Using XPath: Getting Parent/child Values
I am using PHP and XPath to parse an XML value. I found a tutorial that showed me how to get node values for each node, but I need to get them by parent/child node relationships. I'll show you what I have below, so I can explain better: Code:

Resource Temporarily Unavailable: Couldn't Spawn Child Process
Everyday I check my error log I find lots of these errors:

[DATE & HOUR] [error] [client IP X.X.X.X] (35)Resource temporarily unavailable: couldn't spawn child process: /usr/local/httpd/php4-fat/php, referer: www.#*$!.com

[DATE & HOUR] [error] [client IP X.X.X.X] (35)Resource temporarily unavailable: couldn't create child process: 35: php, referer: http://www.#*$!.com

[DATE & HOUR] [error] [client IP X.X.X.X] (35)Resource temporarily unavailable: couldn't spawn child process: /usr/local/httpd/php4-fat/php, referer: http://www.#*$!.com

[DATE & HOUR] [error] [client IP X.X.X.X] (35)Resource temporarily unavailable: couldn't create child process: 35: php, referer: http://www.#*$!.com

Sometimes my includes dont work or I get 500 Internal server errors.

I was told that some PHP processes could be hanging around in the process table, preventing the spawnning of new processes, but I really doubt it since I have low traffic and my php applications arent that complex.

Does anybody know how to get rid of those errors?

Instantiate Child Object From Inside Parent Constuctor?
Is it possible to instantiate a child class within the constructor of its
parent?

eg

Class DBI extends DB {
function DBI() {
// explicit parent constructor call
$this->DB();
$class = get_class($this);
if ($class != '' && $class != 'dbi') { // only do this
for child classes
$obj = new $class; // BORK!!

<snip>

I thought the syntax would be

$obj = new DBI::$class;

but that throws the lovely Hebrew error:

parse error, unexpected T_PAAMAYIM_NEKUDOTAYIM

Dynamic Download Link - Not Direct File Link
I'm posting a podcast feed that makes reference to audio files for download. Instead of linking to the files directly (e.g. www.mywebsite.com/podcast.mp3), I want to link to the file as get variables so that I can track number of listeners (e.g. www.mywebsite.com/?audio=podcast.mp3). Where would I look to get something like this to work? How do I start sending audio data to the user using a link like this?

Solaris/Apache, Child Pid 3383 Exit Signal Segmentation
I cant get php to work on soalaris 8

when I start apache:

[Mon Mar 8 11:39:59 2004] [notice] Apache/1.3.27 (Unix) PHP/4.3.2
configured -- resuming normal operations

but when I got to my test.php page:

which is <?php phpinfo(); ?>

Then I get a page cannot be displayed page.

then in the apache error logs:

Mon Mar 8 11:40:32 2004] [notice] child pid 3383 exit signal Segmentation
Fault (11)
[Mon Mar 8 11:40:32 2004] [notice] child pid 3382 exit signal Segmentation
Fault (11)
[Mon Mar 8 11:41:31 2004] [notice] child pid 3384 exit signal Segmentation
Fault (11)

What do I need to do?

I installed the SFWmphp package from soalris 9 which I installed on solaris 8.

How Can I Kill A Running Child Process When Client Closes Connection
running PHP5 under Apache 2.2 (prefork) as module, I call a Python script that does a sometimes lengthy MySQL query, using parameters supplied by the browser client. When the query takes too long, the user may want to press the STOP button and issue a different query. But the previous child process will run to completion in any case, wasting server resources at the very least.

In the current setting there seems to be no way to forward the user action to kill the child process. The system() call is blocking, and the only chance to see the closed connection in the PHP script is after it has returned.
Is there a work-around? I'm advised not to use the pcntl_fork() etc. in embedded PHP. Are there other possibilities?

Please don't say I should have done everything directly in PHP, without a system() call. I'm much better in Python, that's the reason why, and also I think the call to execute_query (or whatever it is called) directly from within PHP will block as well.

Any suggestions, best proven real-life solutions, are welcome. I thought this must be an everyday problem, or?

Determine If User Came From Inner Link Or An Outside Link
any php method or function to determine if a user came from within the website or from an outside website. I have a page that I want to display in different manners depends on how did the user arrive at my site.

I know about the HTTP_REFERER function. but don't really know how to use it. I know this is the syntax:

<?php
echo $_SERVER['HTTP_REFERER'];
?>

but when i entered the code in the php page. for instance test.php, there is nothing coming up. So my questions:

1. is there any other method?
2. could any of you maybe specify a bit more details about this function and how to use it.

Add Element On The Page
I'm creating a web page to allow the user to change their web page by filling the form. In my form, I use JavaScript to change the properties on their page at the iframe in the same page on my form page. I know Javascript is the client programming, that can change the content of the file in server. I also use PHP to handle to change the content of file (web page) in server. It is not difficult to change the properties on the page at the iframe, however, if i want to allow the user to add element, let says adding a paragraph below the paragraph is existed on the page. How can I add more elements(image, link, heading...etc.) on the page or any function can do so?? How can do it in screen (change the visual page) maybe by JavaScript and how can change the content by using PHP?

Does An Array Contain An Element?
I'm using PHP 4.4.4. Is there a shorter way to check if an array has
an element besides doing a for loop and iterating through each element?

Is The Element Of An Array The Last One ?
What is the best way to solve the next problem: PHP Code:

Getting Element Only Once In Array
I've got an array like so: 1,1,5 But I want to try and make it so if it has the ID appearing more than once then it won't be in the array multiple times. i.e. I want the above to say 1,5.

How To Get Array Element?
get_the_category() returns an array that looks like this:

ResourceArray ( [0] =stdClass Object ( [cat_ID] =3 [cat_name] =>
Certifications [category_nicename] =ms-certifications
[category_description] =Certification Resource [category_parent] =0
[category_count] =5 [fullpath] =/ms-certifications ) )

I want to get the value in "category_description" and have tried:

$category = get_the_category();
$cat_d = $category->category_description;
print_r($cat_d);

But that doesn't print anything. What is the correct way to get the
value I'm after?

Remove Element
I have an array I have included below, it is created by whatever is posted from the previous page. I would like it to remove all of the blank elements if possible. Code:

Array Element
I am having trouble getting a weather sticker php script to work properly. I have been working with the guys that wrote it, but so far they haven't come up with a solution. They/we have narrowed it down to the section of the script that compares a text string (which has been converted into UPPER CASE) from a file generated by the weather station, with an array. It is supposed to match an index in the array, that points to which graphic file to generate. This works about 30% of the time.

(When the text string is VERY SIMPLE - like CLOUDY or CLEAR or RAIN) But not when the text string is more complex, like HEAVY RAIN, MIST OVERCAST, LIGHT RAIN or PARTLY CLOUDY.

Here is the line that defines one of the elements in the array:

Quote $vws_icon["PARTLY|MOSTLY+CLOUDY|SUNNY+THUNDERSTORM"] = "./icons/" . "$daynight" . "_tstorm.$image_format";

I did not incluse the whole script, nor the whole array because of its length.

My Question (Finally...) is --- in the line above within the square braces, he has enclosed a string in double quotes, but the string is delimited by | characters and + characters. Can someone explain to me in English what this means? I have tried reading through two big reference books on php arrays, and they only made me even less certain. (For example: "the line means - If the string is PARTLY or MOSTLY CLOUDY or SUNNY and THUNDERSTORM, then set $vws_icon to whtever the $daynight._tstorm.$image_format evaluates to.)

I know, my example translation makes NO SENSE in English. Maybe it makes no sense in php either? I think what he's trying to ask is "If the string contains 'THUNDERSTORM' and any of these other words, then generate the correct icon file for thunderstorm".

Append "string" To Uniqe ID?
Hi, I'm using a this to generate a unique ID:

$id = (substr(uniqid (""), 2, 7));

example output >> c846dd1

I'd like to append "abc" to beginning of the id.

eg. abcc84dd1

Append Text At End Of Existing Text On Same Line
I'm working on a part of my web site that uploads images, then writes the name of the image to a text file. The upload part works fine. The part that writes the name of the image to the text file works fine.

What I'm trying to do is, after all the files have been uploaded and all of the image names have been written to the WriteTo.txt file, append a written description of the picture at the end of the picture name. In other words, after a user uploads their pictures to the server I want to direct them to a page where they can label each of the pictures using a form. PHP Code:

Delete Array Element
How can i delete an element from one array. Let us suppose that i've an array of 10 elements $a[0], $a[1], $a[2]...etc
And when i delete $a[2] i wanna the elements to be re-ordered like this
$a[0] will be the same $a[0]
$a[1] will be the same $a[1]
but $a[2] will be the $a[3] element i had before deleting $a[2]

It would be called in Delphi, HOW TO DELETE AN ELEMENT FROM A COLLECTION? Is this possible? Have i to use another type of data?
Hope you've understood the idea.

Deleting An Element In An Array??
Here is the problem:

I've got an array with the following elements

$array = ("ice","ice","polka","skate","polka");

thats 2 polka, 2 ice and 1 skate

Now i want someway of removing just one of the polka's from it..

so that i'd be left with:
$array = ("ice","ice","skate","polka");

what i did was a basic search with for loop and break

Code: for($x=0;$x<sizeof($array);$x++)
{
if($array[$x] == "polka")
{
echo("match ".$x);
break;
}
} alls well n good till now.. now i've got the index value(2 in this case) of the element which needs to be deleted.. but what should be done now?? is there any function which'll let me delete a particular element in an array?

Is there any other way to go around this?

Deleting An Element From An Array
I'm not being an idiot here and missing something very obvious as I seem to be prone to doing.

I have the following code:

Editing An Element Within An Array
I have a two-dimensional array that looks like this:
array(
array(0, 123),
array(0, 234),
array(0, 345),
array(0, 456)
)
I want to REMOVE any element that contains 234, and I want to
INCREMENT the first value for any element that contains 345, to make
it look like this:
array(
array(0, 123),...

How To Substract An Element From An Array
I'm looking for a function which substracts an element from an array. For example,

$array = array ("green", "red", "blue", "grey" );

array_substract($array, "red" );

now it's like I had :

$array = array ("green", "blue", "grey" );

notice that the order should be preserved!

Foreach Element In $_POST?
Is there a way to go through each element in the $_POST supervariable?

I'm making a page with dynamic forms, so I don't know for sure how many
$_POST variables there will be (the number of textboxes, radio buttons,
etc changes).

How can I either count them or do a foreach loop to do this?

Missing Array Element
I am trying to store the id's for 3 hotel rooms into an array called
$rooms, using a simple mysql select statement. Here is the code:

<?php require_once('Connections/Vita_Italiano.php'); ?>
<?php mysql_select_db($database_Vita_Italiano, $Vita_Italiano);
$query_rsAllRooms = "SELECT * FROM room";

$rsAllRooms = mysql_query($query_rsAllRooms, $Vita_Italiano) or
die(mysql_error());

$row_rsAllRooms = mysql_fetch_assoc($rsAllRooms);
$totalRows_rsAllRooms = mysql_num_rows($rsAllRooms);

// create array of all rooms
while ($row_rsAllRooms = mysql_fetch_assoc($rsAllRooms))
{
$rooms[]= $row_rsAllRooms['Room_Number'];
}

?>

When I use <?php print_r($rooms);?> to display the contents of the
variable, the array only contains 2 room numbers, instead of 3. These
are stored in $rooms[0] and $rooms[1].

Does anyone have any ideas what is going on here?

Random Element(s) Select?
I'm trying to create a page that displays an image, but also has a specific text string and link associated with that image. There are 5 images, and I want a way to select randomly one of these images with its appropriate info.

I've seen a lot of scripts already that select an image from a text file, or a database, or a directory of images, but I want to do it with arrays. I suppose I would have to use associative arrays. PHP Code:

Breaks In Form Element
I have been having a whole lot of trouble trying to get this to work. I am using the code below for my Content Management system. The field 'content' is the field that needs to have the auto <br /> turned off. I am using the code below to insert pages into the database. The pages have HTML included within them and are formatted using Dreamweaver, so they look nice and neat.

After the script is done running, the page entered had extra <br />s added to it. Could someone please help me get rid of them, been looking all over the place and have tried a lot, no luck though PHP Code:

How To Change Css Id In Span Element?
How to change a link's color based on a php variable?

I have a number of links on a page:

<p><a href="page1.php">Page 1</a></p>
<p><a href="page2.php">Page 2</a></p>
<p><a href="page3.php">Page 3</a></p>
<p><a href="page4.php">Page 4</a></p>

I want the link to be red if $nav has a value that corresponds to the page
number: If $nav = 1, then the page1.php link should be red; if $nav = 2,
then the page2.php link should be red, and so on.

This is how I'd normally code the html to make a red link:

<p><span id="red"><a href="page1.php">Page 1</a></span></p>

But how do I check the value of $nav and insert the appropriate span id for
each link? Can I somehow make the span id a variable? How to I jump in and
out of php within a tag?

If $nav does not correspond with the link's page number, then the link
should remain the default color - which is blue:

<p><span id="blue"><a href="page1.php">Page 1</a></span></p>

Missing Element In Array?!
I have the following query I run to pull some data from the db. The
sql (when run on the db) returns 2 elements. However, if I var dump my
variable ($aidlook) then the first element in the array does not show
up.

$getaid = mysql_query("SELECT a_uid FROM `answers` WHERE `qid` =
$qid", $db);
$aidlook = mysql_fetch_array($getaid,MYSQL_NUM);

Doing a var dump returns: array(1) { [0]= string(1) "4" }

I should be getting 2 elements (4 and 5).

I am totally baffled. code as follows:

*********************
if (!is_array($aidlook)) $aidlook = array($aidlook); // Check for the
existence of the array in case of null returns

if (!in_array($userid,$aidlook)) // Look for our element which in
this case is "5"
{
if ($qstatus === 1) // Do a status check
{
}

answer_box($qid,$answ); // additional function being run

} else
{
echo "Your Text Here";

}
}

Deleting An Element Of An Array?
How can I delete an Element of an array? Consider the following Example: PHP Code:

Eliminate An Element Of An Array
I want to eliminate the last element of an array, couse when I print it, it doesn´t have any value. I tried to use array_pop but it doesn´t work.

Deleting An Element From An Array
is there some handy and short method to delete an element from an array and than shifting the rest of elements one place ahead
e.g

array(1,2,3,4,5,6)
becomes
array(1,2,4,5,6)


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