How to write a query for PHP and MySQL?

Let’s learn how to write a query for PHP and MySQL. The most accurate or helpful solution is served by Stack Overflow.

There are ten answers to this question.

Best solution

how to write php MySql query

I would like to be able to make a selection from a select-box and view the selected table. My skill level with php/MySQL at this point is: $query = "SELECT * FROM electrical ORDER BY item_id LIMIT $offset, $RPP"; With this query the div is populated on page load. I have a select box that has 6 choices: <form> <select name="dbtables" onchange="showTable(this.value)" id="selectBox"> <option value="">Select a materials table:...

Answer:

in your index.php pick the $str value using $_GET method and construct the query. then run that query...

Read more

ussteele at Stack Overflow Mark as irrelevant Undo

Other solutions

Simple PHP/MySql Question Regarding Arithmetic Function

I'm a very novice PHP/MySql programmer, and I'm building a page that will display results from a MySql database, using PHP. It's quite elementary, but I've developed a brainlock over it. Here are the facts: The MySql database logs in user registrations...

Answer:

Hello: Show the information you need could be done in two steps: -First: Extract the data from the...

Read more

catullus13-ga at Google Answers Mark as irrelevant Undo

Php mysql how to display the number of albums an artist has?

$dbQuery="select id, name from artists where name like '$keyword%' order by name asc limit 15"; $dbResult=mysql_query($dbQuery); echo mysql_num_rows($dbResult)."\n"; while ($dbRow=mysql_fetch_array($dbResult)) { // for each artist...

Answer:

you'll probably have to us a join with another table. but as you don't describe wihch tables you have...

Read more

Laura at Yahoo! Answers Mark as irrelevant Undo

php, mySQL, and HTML Entering an SQL query directly into an HTML form

QUESTION: Why can't I paste the following SQL into the form I have created and have it work when it works in phpMyADMIN? INSERT INTO foods VALUES ("REFRIED BEANS","CANS",30) The successful answer will explain to me why taking the...

Answer:

Hello Tom I'm glad I could help solve your problem. The problem was indeed caused by the use of "...

Read more

hawstom-ga at Google Answers Mark as irrelevant Undo

How to read a mySQL query (through PHP) into JavaScript variables using AJAX?

Hi, I have written an AJAX program that interfaces with a mySQL database through PHP pages. Inserting records is no problem at all but I have not figured out how to read a query into individual JavaScript variables yet. I'd like the query results to...

Answer:

You have the PHP page return text that creates a JavaScript array, e.g.: <?php echo "var myArray...

Read more

John at Yahoo! Answers Mark as irrelevant Undo

$query command syntax problem with php (MySQL)?

When I try to make a MySQL query string ("SELECT Name, Desc, Link FROM Site") I get this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Desc, Link...

Answer:

Sorry im not being smart but none of that makes any sense to me.. What is an SQL version 4. 1. 22 standard...

Read more

Tom at Yahoo! Answers Mark as irrelevant Undo

MySQL Query SUM() function (in PHP)?

Hi, my problem is when I try to run the MySQL SUM() function through PHP it just returns a completely blank array. Here is my PHP code (modified): $var = mysql_query("SELECT SUM(uniques) FROM stats WHERE unqiues BETWEEN '1000' AND '2000'")...

Answer:

The mysql_query() function returns a result handle (a reference to a list of results that then need...

Read more

Ben Ja Min at Yahoo! Answers Mark as irrelevant Undo

MySQL query to two databases via php.

On my Win2000/IIS5 server, I have two mySQL databases ("NYC" and "LA") on a single server. Tables in the databases are the same (e.g. DB1 has the same tables as DB2). Table "employees" in each database has fields "fname...

Answer:

Hi, There are two ways we can do this; a) use a temp table to place the results from this query into...

Read more

pmj2-ga at Google Answers Mark as irrelevant Undo

PHP / MySql query and/or script

tablePkId | userFkId | colorFkId | ----------+----------+-----------| 1 | 11 | 22 | -- ----------+----------+-----------| 2 | 12 | 25 | YES ----------+----------+-----------| 3 | 13 | 25 | YES ----------+----------+-----------| 4 | 14 | 25 | -- ----...

Answer:

Klausb-ga, Thanks for your interesting question! The problem can be solved with the following SQL query...

Read more

klausb-ga at Google Answers Mark as irrelevant Undo

Wonder if there are anyone with experience to write/deal with specification/SOW for web projects (Php, MySQL, and MongoDB) when it comes to security but also benchmarking / performance and scale?

We are in the process of invest and building a new platform for our "City Destinations" venture which is hybrid of news/magazine and social network with added services like places/business guide, real estate and much more. It will be both web...

Answer:

In the realm of PHP vulnerabilities I'd say you should definitely invest some time/research in PHpass...

Read more

Bryan Fajardo at Quora Mark as irrelevant Undo

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.