Re: Date Rows
| From: | Philip Olson | Date: | Wed, 10 Oct 2001 04:17:33 +0000 |
| Subject: | Re: Date Rows | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-70579@lists.php.net to get a copy of this message | ||
hello devon-
looks like you meant to use mysql_fetch_assoc() instead of mysql_query()
just a little typo :)
also, variable names ArE cAsE sensitive. $foo does not equal $Foo.
here's a quick rewrite of your code, hopefully it helps your quest in
becoming a php programmer :
$conn = mysql_connect($host,$user,$pass);
$db = mysql_select_db($dbname);
$query = "SELECT * FROM $tablename WHERE date='$date'";
$result = mysql_query($query);
if (!$result) {
print mysql_error();
exit;
}
$row_count = mysql_num_rows($result);
while ($row = mysql_fetch_assoc($result)) {
extract($row);
print $indata;
print $outdata;
}
print "<b>$row_count</b>";
also, keep in mind that mysql_db_query and mysql_query both query the
database, don't use both. hopefully the above example helps explain.
please sift through the manual a little more, look up all these functions
your using and understand their meanings, there are quite a few :-)
also, you may or may not have issues with retrieving by date since there
are a bazillion ways to store dates, be sure to also play with :
http://www.mysql.com/doc/D/a/Date_and_time_functions.html
regards,
Philip Olson
p.s. i used mysql_fetch_assoc, it's 4.0.3+ function. if that's an issue,
use mysql_fetch_array or similar instead.
On Wed, 10 Oct 2001, Devon wrote:
> Below is my script were I am trying to print specific rows of a data base by
> using date as the ID, I do not recieve any output can someone please help>?
>
> <?php
>
> $host = "192.168.1.203";
> $user = "sc";
> $password = "sc";
> $dbname = "Syd-01";
> $tablename = "Port1";
> $date = "2001-10-05";
>
> $link = mysql_connect ($host, $user, $password);
> $query = mysql_query("SELECT * FROM $tablename WHERE date='$date'");
> $result = mysql_db_query($dbname, $query, $link);
> while ($Row = mysql_query ($Result)) {
> print $row[indata];
> print $row[outdata];
> }
>
> mysql_close($link);
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>