Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

php and mysql query

Posted on 2001-08-21
1
Medium Priority
?
704 Views
Last Modified: 2008-02-01
I want to know how do get the results from this query

mysql> SELECT PERIOD_DIFF(20010101,20010110) as days;

to a variable in my php script

I am have no problems connecting to my database or query tables in my database but i don't know how to the the results of this query to a variable in my script.

This is what I have so far:
<?PHP
$login="mylogin";
$pass ="mydbpass";
$db=mysql_connect("localhost",$login,$pass);
mysql_select_db("mydb",$db);
$sql = "SELECT PERIOD_DIFF(20010101,20010110) as days";
$result=MySQL_query($sql,$db);

//This is where I am stuck
$diff_days = //result from mysql query
echo "$diff_days<br>";

?>";


Please Help!
0
Comment
Question by:onestar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
KestasS earned 150 total points
ID: 6410005
Just use function mysql_fetch_array (more info in www.zend.com)

For example you can fill select options:
<select name="cmbOwner">
    <? while ($myrow = mysql_fetch_array($rstOWNER)) {  
           echo"<option>";
          echo $myrow["name"];
       echo "</option>"  ;}   ?>
    </select>


In your case it will be :
<? echo $myrow["days"]; ?>

Good luck !

Kestas

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question