Re: Date rows
| From: | Jason G. | Date: | Wed, 10 Oct 2001 04:34:30 +0000 |
| Subject: | Re: Date rows | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-13180@lists.php.net to get a copy of this message | ||
Hmmm... I see what seems to be some serious problems in the attached code.
sudo code:
Connect to MySQL - or die() with an error message
Select your DB - or die() with an error message
Execute query using mysql_query()
Get number of rows from result
Loop through result
{
fetch array from result
display contents of array
}
//Both of the lines below will happen at the end of the script automatically
free the result
close the mysql connection
----------------------------------
REAL CODE
$host = "192.168.1.203";
$user = "sc";
$password = "sc";
$dbname = "Syd-01";
$tablename = "Port1";
$date = "2001-10-05";
$link = mysql_connect ($host, $user, $password) or die("could not connect to db");
mysql_select_db($dbname, $link) or die("could not select db");
$query = "SELECT * FROM $tablename WHERE date='$date'";
$result = mysql_query($query, $link) or die("query failed!");
$rowcount = mysql_num_rows($result);
for($i=0; $i<$rowcount; $i++)
{
$aRow = mysql_fetch_array($result);
print $row["indata"]; //Note the quotes...
print $row["outdata"]; //Note the quotes...
}
mysql_free_result($result);
mysql_close($link);
At 12:52 PM 10/10/2001 +1000, 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"; while ($Row = mysql_query ($Result)) { } mysql_close($link); -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net