getting rows by an ID field or by another field in a table

getting rows by an ID field or by another field in a table

am 06.12.2005 20:42:34 von Eternity Records Webmaster

I have a table with the fields:
CREATE TABLE `journal` (
`Date` date NOT NULL,
`subject` varchar(100) NOT NULL,
`entry` longtext NOT NULL
) TYPE=MyISAM COMMENT='Journal table';

I was wondering if I should get the rows out by an ID field of some kind or
maybe do a select on the subject? what would be the real best way? I am
trying to get the date/subject to list on a webpage in a table and then when
someone clicks on the subject (it will be a link), it will take them to a
popup window (target=_blank) and then display the whole entry
date/subject/entry. whats the best practice for that sort of thing?

thanks

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: getting rows by an ID field or by another field in a table

am 06.12.2005 20:50:54 von Joseph Crawford

------=_Part_13892_25509254.1133898654530
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

i would do something like

SELECT id, date, subject FROM journal LIMIT 20

ofcourse this would mean you have to add an id column to your table and i
would make that a primary key and auto_increment,

this way when you do the select you could do something like this

$res =3D mysql_query("SELECT id, date, subject FROM journal LIMIT 20");
echo '

';
echo '';
while($entry=3Dmysql_fetch_array($res)) {
echo '';
}
echo '
SubjectDate
?id=3D'.$entry['id'].'">'.$entry['subject'].''.$entry['date'].=
'
';


--
Joseph Crawford Jr.
Zend Certified Engineer
Codebowl Solutions, Inc.
1-802-671-2021
codebowl@gmail.com

------=_Part_13892_25509254.1133898654530--

RE: getting rows by an ID field or by another field in a table

am 06.12.2005 23:02:12 von Bastien Koert

Adding an ID field allows you to quickly point back to any particular record
if you manage to have duplicate data...

Bastien


>From: "Eternity Records Webmaster"
>To:
>Subject: [PHP-DB] getting rows by an ID field or by another field in a
>table
>Date: Tue, 6 Dec 2005 14:42:34 -0500
>
>I have a table with the fields:
>CREATE TABLE `journal` (
> `Date` date NOT NULL,
> `subject` varchar(100) NOT NULL,
> `entry` longtext NOT NULL
>) TYPE=MyISAM COMMENT='Journal table';
>
>I was wondering if I should get the rows out by an ID field of some kind or
>maybe do a select on the subject? what would be the real best way? I am
>trying to get the date/subject to list on a webpage in a table and then
>when
>someone clicks on the subject (it will be a link), it will take them to a
>popup window (target=_blank) and then display the whole entry
>date/subject/entry. whats the best practice for that sort of thing?
>
>thanks
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php