Solved

php and mysql query

Posted on 2001-08-21
1
701 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 50 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

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…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

632 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