Jump to content
xisto Community
Sign in to follow this  
karlosantana

PHP and SQL calling table value issue Im Stuck Again

Recommended Posts

I have no idea why the heck I'm struggling with this, I'm usually the one giving the help for this sort of thing! Anyway here goes: It's my date comparison script again, I've added the abbility to select "from" and "to" using THIS script I've made the code below

<?php	require_once 'class.sql2csv.php';		$params = array(		'host'		=> 'localhost',		'user'		=> 'root',		'password'	=> '',		'database'	=> 'database_name'	);	$query = "SELECT * FROM form_data WHERE (sd >='_$date') and (sd < '_$date2')";	new SQL2CSV($params, $query);?>

Now what's happening is: it'll pick up "date2" but not "date" and I have no idea what the heck is going on! I've tried all that I know to try and get it right, I'm still confusled!

I'm left in your capable hands, thanks in advance
Kyle

Share this post


Link to post
Share on other sites

*UPDATE*
I have now made it easier to see what I mean, a link to the site can be found HERE and you can take a look at the code HERE. You may have noticed I've added $_POST in the dump_data file. I was trying another way of skinning this cat!
Thanks again
Kyle

Share this post


Link to post
Share on other sites

If you're still having problems try this:

<?php//log into the database$dbhost = 'localhost';$dbuser = 'username';$dbpass = 'password';$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die					  ('Error connecting to mysql');$dbname = 'dbname';mysql_select_db($dbname);// get the sql info$query = mysql_query("SELECT `date`,`date2` FROM `dbtable` WHERE `id`=" . mysql_real_escape_string . " LIMIT 1");//then you need to get the result into an array$result = mysql_fetch_assoc($query);?>
Then to show the result:
{$result['date']}{$result['date2']}
Hope that works.
Edited by Soviet Rathe (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.