|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
print echo specific, single cell from mysql database
Sounds simple to me, query my mysql database for the cell Robert and MOCi (which happens to equal the integer: 51)
Here is the main part of what I have tried so far: $sql_query = "SELECT Name, MOCi FROM mydatabase WHERE 1 AND Name = Robert"; //store the queried cell in the variable //named $result $result = mysql_query($sql_query); //display the queried cell echo ($result); This "echos" nothing but gives not errors either. It seems that all the example code I find out there is based on arrays. This should be basic, but I am fairly new to all this. thanks in advance for your help! |
|
#2
|
|||
|
|||
|
RE: print echo specific, single cell from mysql database
$result is actually a 'result set'. You must now retrieve some data from the result set..try this:
$sql_query = "SELECT Name, MOCi FROM mydatabase WHERE 1 AND Name = Robert"; //store the queried cell in the variable //named $result $result = mysql_query($sql_query); //get one row of data from the result set $row = mysql_fetch_array($result); //display the queried cell echo ($row['MOCi']); |
|
#3
|
|||
|
|||
|
RE: print echo specific, single cell from mysql database
Cheers Anonymous but...I had to resort to the following:
//this is supposed to query the database for //the exact cell needed $sql_query = "SELECT MOCi, Name FROM moc_db1 LIMIT 3, 1"; // "SELECT Name, MOCi FROM moc_db1 WHERE 1 AND Name = Robert" //gives: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource ___________________ NOTE1: Using the LIMIT parameter I can, in effect specify the name, but this is awkward. For some reason the Name = Robert gives the error above NOTE2: SELECT can be * (all the data) since only the desired column is printed in this command: echo ($row[MOCi]); OUTSTANDING QUESTION: Any idea why the mysql_query does not like me specifying Name = Robert - or something similar? (I cut and pasted the mysql code straight from phpmyadmin just be sure and, no good). It would be much cleaner to specify the cell without LIMIT. cheers. |
|
#4
|
|||
|
|||
|
It DOES work with Name = Robert
Isert this in any of the scripts above and they should work:
Name = 'Robert' Since this is the default text format in a text field Name = requires ' ' all works fine now. thanks again anonymous |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > print echo specific, single cell from mysql database |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|