How to make query into arrays?

I'm using this code to gather information from database

$webdata = "SELECT * FROM `settings`";
 if (!$web_data = $db_connect->query($webdata)) {
     die('Oops, something went wrong during loading data! Error x010');
 }

but now I would liek to display it like arrays so taht I can just simply use this code:

<?php echo $web_data['web_name']; ?

to display the information

Answers


Since you tagged this mysqli, you need to fetch the results into an array.

You can do so with mysqli's fetch_assoc():

$webdata = "SELECT * FROM `settings`";
if (!$web_data = $db_connect->query($webdata)) {
     die('Oops, something went wrong during loading data! Error x010');
}

while ($row = $web_data->fetch_assoc()) {
    echo $row['web_name'];
}

Echo will just send Array text in response. To send an array use print_r function.


Need Your Help

Linq results to IEnumerable invalid cast

c# .net linq ienumerable

Question for Linq users out there: I'm getting an InvalidCastexception: Specified cast is not valid whenever I try to obtain an IEnumerable from revs after making the Linq query. There database is

Presenting modal dialogs from XIB in Cocoa: best/shortest pattern?

objective-c cocoa modal-dialog xib nswindowcontroller

Below is my typical WindowController module for presenting a modal dialog (could be settings, asking username/password, etc) loaded from a XIB. It seems a bit too complex for something like this. Any

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.