2

I have a mySQL database table setup called site.

Rather than qet the column headings to produce a PHP object of values I want to produce data from the rows.

TABLE: site

:::field:::::value:::::

   url       www.example.com
   name      example site
   etc       Example Etcetera

So I want to be able to get this information from the server by calling the column name I want and the row I am after. I want to do this for all fields in site as I don't want to do multiple calls for the various different rows in site; I'd rather store all the information from the beginning in the object:

eg. <? echo $site['url']; ?>

I created this put it appears to be causing an error:.

$sql = "SELECT * FROM `site`"; 
$site[];
foreach($sodh->query($sql) as $sitefield){
    $site[$sitefield['field']] = $sitefield['value'];
}

Obviously I've missed something. ¿Any idea as to what?

1 Answer 1

2
$site[];

should be

$site = array();
Sign up to request clarification or add additional context in comments.

1 Comment

OK but that has not fixed the problem

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.