Solved

PHP Echo array question

Posted on 2014-11-07
5
112 Views
Last Modified: 2014-11-16
Having a hard time to echo $agentsStuff within this line of code:

schema (echo $agentsStuff[bizID]1,10);

Open in new window

0
Comment
Question by:seopti
  • 3
  • 2
5 Comments
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 40429212
Please run this PHP instruction and post the output here, thanks.

<?php var_dump($agentsStuff);

Open in new window

0
 

Author Comment

by:seopti
ID: 40429264
I have a bizID for each business in the database which I can echo with:

<?php echo $agentsStuff['bizID'];?>

Now I've installed an addon which adds schema org. It is printed this way:

<?php schema('someItemID');      //print schema.org rich snippets  ?>

What I would like to do is to echo the bizID as someItemID. I tried this for a few hours without success.
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 40429527
I tried this for a few hours without success.
Don't waste your time like that.  Just work with me.

Please run this PHP instruction and post the output here, thanks.

<?php var_dump($agentsStuff);

Open in new window

0
 

Author Comment

by:seopti
ID: 40430390
When I do var_dump  on $agentsStuff I get:

array(30) { [0]=> string(6) "624082" ["bizID"]=> string(6) "624082" [1]=> string(9) "Attorneys" ["bizCatSub"]=> string(9) "Attorneys" [2]=>  .....

And there is the bizID which I need echoed as someItemID.
0
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 40430449
It looks like you've got a results set from a query, and you've used MySQL_Fetch_Array() to retrieve the data.  That's an AntiPractice (see number 27 for an explanation of why you want to change that).

To get a different column name in the results set, and therefore a different key in the array, you can change your query to use the AS clause in the SELECT query.  Example:

SELECT bizID AS someItemID FROM myTable...

I don't understand part of this question about this line of code:
schema (echo $agentsStuff[bizID]1,10);

Open in new window

What is schema()?  Is it some kind of locally defined function?  What does "1,10" mean in this context?
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Detect Closed Loops (circles, figure-8s, etc) in PNG Images 6 56
two ways encryption with php 3 37
MVC - procedural PHP 10 35
Help with PHP 13 27
These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question