[PHP-DB] get a total comment listing

2004-01-08 Thread js
im making a website where visitors can comment on essays that they read. i have a 
table that contains every comment written and each comment has its own ID for primary 
key and articleid column for which essay it is written for. now, i want to be able to 
tally up how many comments there are for each particular article on  a page that sums 
up all of the essays for a user, so that you can tell which ones have had new comments 
and which havent. its quite basic, but im stuck as far as what to do. any help would 
be great, thanks.
-james

[PHP-DB] CREATE TABLE problem

2004-01-21 Thread js
ok im making this page and every single time i try to execute it, it tells me it was 
not successful. the database name, user,pw,and local host are all correct. i have no 
idea what do do, and i have 2 more tables besides this one i wanted to create but this 
was kind of my template for it and i cant even get it to work. im still really bad 
with this kind of stuff so any help i could get from you is really appreciated. 
thanks. here is the code:

html
head
titleUntitled Document/title
/head

body
?php

$host = localhost;
$user = user;
$password = ;
$dbname = swwdb;

$link = mysql_connect($host,$user,$password);

$query = CREATE TABLE staff (
 staffid INT(3) NOT NULL AUTO_INCREMENT UNSIGNED,
 name VARCHAR(255) NOT NULL,
 login VARCHAR(10) NOT NULL,
 password VARCHAR(8) NOT NULL,
 picaddy VARCHAR(255) NOT NULL,
 email VARCHAR(255)  NOT NULL,
 staffbio TEXT NOT NULL,
 createdate DATE NOT NULL,
 tagline VARCHAR(255) NOT NULL,
 PRIMARY KEY(staffid,login) );

if (mysql_db_query ($dbname,$query,$link)) {
 print (the query was successfull);
} else {
 print (the query was NOT success);
 }
 
mysql_close($link);
?



/body
/html


[PHP-DB] CREATE TABLE problem redefined

2004-01-21 Thread js
ok i did the mysql_error DIE thing, and now it tells me this: 

You have an error in your SQL syntax near 'UNSIGNED, name VARCHAR(255) NOT NULL, login 
VARCHAR(10) NOT NULL, password' at line 2

i have no idea what it means. i dont think any of those are taken or reserved by PHP 
or mySQL. any further help would be great. thank you.
-james

[PHP-DB] counting a value

2004-01-30 Thread js
i want to know what i can use to count the number of times a value appears in a column 
listing where different values are listed. for example, say in the column of Favorite 
Number we have 100 students, and for each student his or her own row. and each student 
can pick a number from 1-10. So, we have a column of 100 rows and each field can 
contain either 1-10.Now, i want to know how can i count the number of times  lets 
say the #2 appears in this list and give that count a number. so if #2 appears 43 
times in that column, then i want it to say 2 is listed 43 times.  how do i do this? 
thank you for your help with my beginner newbie questions.
-james

[PHP-DB] counting a value REVISED pt2

2004-01-30 Thread js
p.s.- im using PHP with MySQL... if that helps any. thanks
i want to know what i can use to count the number of times a value appears in a column 
listing where different values are listed. for example, say in the column of Favorite 
Number we have 100 students, and for each student his or her own row. and each student 
can pick a number from 1-10. So, we have a column of 100 rows and each field can 
contain either 1-10.Now, i want to know how can i count the number of times  lets 
say the #2 appears in this list and give that count a number. so if #2 appears 43 
times in that column, then i want it to say 2 is listed 43 times.  how do i do this? 
thank you for your help with my beginner newbie questions.
-james

[PHP-DB] mysql date/time question

2004-01-31 Thread js
ok, 2 questions. first, how do i do a mysql query that orders by date? like, say i 
want to have 5 newest members who have signed up? i want it to display only 5 also. 
how do i do that? like this? 

$newestquery = SELECT artid,title,artdate,artauthor FROM article WHERE artdate = 
$today ORDER BY artdate DESC LIMIT 5;

and also, my next question is how do i format the display of date and time from how 
MySQL stores it to where i want it displayed differently in PHP? like, mysql will 
store it as -DD-MM  and i want it displayed in php as date(n.j.y.) and time 
displayed as $time = date(g:ia);   my time and date columns are 2 different columns 
in my TABLE, and i want to know how to format the date to enter into mysql and how to 
format it when i retrive it from mysql. thanks for your help.

-james (im a newbie programmer)

[PHP-DB] page hit tracking

2004-02-06 Thread js
i am using php MySQL and i want to know how i can make a hidden value for certain 
entries in a table and how many times they are called. for instance, say i have a 
table of vegetables people can look at. the page displays all of the vegetables, and 
then it generates links to each one and if the user clicks on one then the page just 
calls itself and displays more information about the vegetables. now, how do i make a 
counter where theres a field in the table where it increases by 1 everytime someone 
looks at a particular vegetable. i really am new to this so thank you for your help. 
thanks
-james

[PHP-DB] mktime question

2004-02-07 Thread js
i have a page that displays an essay someone has written. and people who come to the 
site can submit comments. the comments are taken quickly in a form and posted. 
everything is posting perfect except for the time to get the time i dont know what 
to use? time() or date() or mktime() ??? im really stuck. i dont know how to submit 
the time to the MySQL database so it takes the correct format for the time area. i 
have a substr() script that formats it when it is retrived and displayed, but i do not 
know how to make the INSERT INTO with the time. if you can help me out i thank you!
-james

[PHP-DB] MySQL query question

2004-02-13 Thread js
i want to search the table called comments, and i want to count the number of times 
artid appears. then i want to group them all together, but then i want to order them 
by most appearances to fewest. so if artid 1 appeared 40 times and it was the most, i 
want that to be retrieved first. if artid 3 appeared 38 times and it was second most, 
i want that retrieved second... etc and so on. this code ive given is wrong, but i 
know that it has to be something like this or that im close. if any of you could help 
me id really appreciate it. if theres a shortcut with this code that would be great, 
otherwise i have to run my php around in a ton of different mysql queries trying to 
find out which has the most and have it ordered from highest to lowest. thank you for 
your help. ive tried mysql.com too and i cant find a thing there. plus the mailing 
lists for mysql, no one ever responds! thank you php list, you are my only hope. ;P
-james



$mostcomquery = SELECT artid, COUNT(*) FROM comments GROUP BY artid ORDER BY 
(COUNT(*)) DESC LIMIT 5;

[PHP-DB] Query Object in PHP?

2007-02-24 Thread js

Hi list,


Is there any implementation of Query Object [1] written in PHP?
I spent some time searching on the net but no clues're found.

Thank you in advance.

[1] http://www.martinfowler.com/eaaCatalog/queryObject.html

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



[PHP-DB] Re: Query Object in PHP?

2007-03-03 Thread js

Ansering myself.

DB_DataObject http://pear.php.net/package/DB_DataObject/

On 2/25/07, js [EMAIL PROTECTED] wrote:

 Hi list,


Is there any implementation of Query Object [1] written in PHP?
I spent some time searching on the net but no clues're found.

Thank you in advance.

[1] http://www.martinfowler.com/eaaCatalog/queryObject.html



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



Re: [PHP-DB] About mysql_connect()

2008-02-06 Thread js
Use PDO and try/catch.
I think it's much easier.

On Feb 6, 2008 7:07 PM, Prabath Kumarasinghe [EMAIL PROTECTED] wrote:
 Hi All

 When I stop mysql database whole application will
 break in mysql_connect() function even without giving
 any error message.Is there are any way to put
 exception handling with mysql_connect() function.

 Cheers

 Prabath




   
 
 Looking for last minute shopping deals?
 Find them fast with Yahoo! Search.  
 http://tools.search.yahoo.com/newsearch/category.php?category=shopping

 --
 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