Solved

PHP Echo array question

Posted on 2014-11-07
5
114 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 110

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 110

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 110

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
This article discusses how to implement server side field validation and display customized error messages to the client.
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 dynamically set the form action using jQuery.

759 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