Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6660943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:13:05+00:00 2026-05-26T02:13:05+00:00

need some enlightment here, and this is my first post here. I would like

  • 0

need some enlightment here, and this is my first post here.

I would like to call and use my previously created mysql view using php… is it possible?
or in another words,
i’m wondering….can we OR how do we call mysql view, that we already created using php? to reduce long query coding

standard generic codes as follow :

$sql= " SELECT shipping.tarrif1, city.city_name
         FROM shipping JOIN city
   ON shipping.id_city = city.id_city";
$db->QueryArray($sql);   

while ($row = $db->Row()) {
echo $row->city_name. " - " . $row->tarrif1 . "<br />\n"; 
}

now for the MYSQL VIEWS :

$sql= " CREATE VIEW shipsumarry AS SELECT shipping.tarrif1, city.city_name
         FROM shipping JOIN city
   ON shipping.id_city = city.id_city";

Pure MYSQL command :

query: SELECT * FROM shipsummary

IN PHP :

 $sql = i'm badly stuck here...please help

How do we access it using php.

thanks before

Addition 1:

ok… let me rewrite the example :

$sql1= " CREATE VIEW shipsumarry AS SELECT shipping.tarrif1, city.city_name
         FROM shipping JOIN city
   ON shipping.id_city = city.id_city";
$sql2= "SELECT * FROM shipsummary";
$db->QueryArray($sql2);

$sql2 can not see shipsummary VIEW, coz it’s already in a different var

how to utilise and then execute $sql1 ? & $sql2?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:13:05+00:00Added an answer on May 26, 2026 at 2:13 am

    The process is the same in PHP – a MySQL view is seen by the client (PHP) as a regular table, so querying it as

    mysql_query("SELECT * FROM shipsummary");
    
    // Or for whatever framework you're using:
    $db->QueryArray("SELECT * FROM shipsummary"); 
    

    should work correctly. If it does not work correctly, the MySQL user with which you are accessing the view may have broken permissions. (Seems unlikely though).

    UPDATE

    After you edited your question, I can see the problem quite clearly.

    $sql1= " CREATE VIEW shipsumarry AS SELECT shipping.tarrif1, city.city_name
             FROM shipping JOIN city
       ON shipping.id_city = city.id_city";
    $sql2= "SELECT * FROM shipsummary";
    
    // Here, you need to execute $sql1 before $sql2 is useful.
    $db->QueryArray($sql1);
    // Now execute $sql2
    $db->QueryArray($sql2);
    

    We don’t know what database class or framework you are using, but if there is a comparable method to QueryArray() that doesn’t return a result set, but just executes a statement, use it to create the view instead.

    Now, all that being said…

    Unless the definition of the view must change every time this code executes, and unless you have a reason to then DROP VIEW shipsummary at the end of this script’s execution each time, it makes far, far, far, far …. more sense to simply create the view in the database, where it will stay forever, rather than to keep re-creating it with PHP. Views, once created, stay created.

    Don’t think of them as a temporary query time/code saver. Create the views you will need ONCE in your database (using PHPMyAdmin or mysql CLI, or however you created your tables), and access them with PHP.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need some best practice advice here... Navigation based application. Root view is a UITableView
I've been working in a time attendance application and need some enlightment. This is
Need some help about with Memcache. I have created a class and want to
Need some help to solve this. I have a gridview and inside the gridview
Need some guidance figuring out what went wrong. I've been using mysql, phpmyadmin for
Need some help with this problem in implementing with XSLT, I had already implemented
Need some help gathering thoughts on this issue. Our team is moving ahead with
I feel like I'm missing something basic here, and I would appreciate it if
Need some help with this error. Fresh wordpress 2.9 install... Fatal error: Cannot instantiate
Need some help on understanding how to do this; I'm going to be running

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.