Page 1 of 1
image slides [Unsolved] (date format is solved)
Posted: Mon Oct 17, 2005 10:43 pm
by Dm7
Ok 2 issues....
1) I used datetime in my database as 00/00/0000 00:00:00 format and i want to convert it to M/D/YY or something... how can I do that? Is there a good tutorial out there that I can UNDERSTAND from? Yes I have used google to find a such tutorial and I haven't found one that I do understand.... there's just a function or something similar.. and I need to create it by my hand because I'm doing it for my portfolio so I have to say that it's 100% mine and I actually understood what I was doing. So... anybody knows a good one?
2) I have viewing page where people view an original image at a time.. and I wanted to make "<<PREV - 1 of 100 images - NEXT>>" thing so they can nagivate easily while they are viewing the images... my database doesn't have IDs in it so I'm wondering if there is a way to get a current row number from the database like... get $row['name'] row then echo what the number of that row is.. like 4th row or something. I am putting it in ORDER BY date DESC order... and I want it to figure out the row number it is without having to use IDs.

Is there a such way to do that?
My aplogoies if I posted it in the wrong section.

Posted: Mon Oct 17, 2005 11:01 pm
by feyd
- If you're using MySQL, DATE_FORMAT() is your friend: http://dev.mysql.com/doc/refman/5.0/en/ ... tions.html
- Each url should reference the offset to where the page should jump into the database query results. You then use the LIMIT or similar logic in your given DBMS.
- Moved to Databases.
Posted: Tue Oct 18, 2005 4:48 pm
by Dm7
I got it working... (the date format thing.. ) thanks
Anyways.. for picture sliding or whatever.. I use $pix to call $_GET[pix] from the url which would be something like view.php?pix=icecream.jpg so how can I identify which row it is in by using $pix var... my sql query is something like..
Code: Select all
SELECT * from $table WHERE name ='$pix'
That's how I select the row where I wanted it to be... so how can I use that query to get row number as well..... and use that for next row number and prev row number so I can call name column for next/prev so I can make a url that would be like this after being reviewed by php first.
Code: Select all
<a href="view.php?pix=ugllly.jpg">PREV</a> - 30 out of 102 images - <a href="view.php?pix=angel.jpg">NEXT</a>
Know what I'm saying? Remember that I don't have IDs with auto-increasment (sp?)... I only use name column to get what I want.
Posted: Tue Oct 18, 2005 6:52 pm
by Dm7
I'm not sure if I'm clear enough... but the reason I'd need to get the number of that selected row so I can get the number for the image.. like 30 out of 102 total images... I can do the total rows without any problems, but I'm suck with how to get number from selected name column by using url referring $pix which would be the filename of that image... so I want to get something like...
Code: Select all
SELECT name FROM $table WHERE name = '$pix' GET row#
I know the command is wrong, but do you know what I'm trying to say now?
Posted: Wed Oct 19, 2005 1:10 am
by ryanlwh
instead of using the filename as a pagemarker, it would be better to use the offset (or row number) and utilize the LIMIT in mysql to get what you want.
Code: Select all
SELECT name FROM $table ORDER BY date DESC LIMIT $offset, 1
Now you don't have to use mysql to determine the row#, because it's the GET variable, and you can also achieve what you want.
Posted: Wed Oct 19, 2005 3:46 pm
by Dm7
the reason why I wanted to use view.php?pix=blah.jpg is because so people can nagivate my viewing page easily and possibly be able to memorize the url easier rather than having view.php?offset=1
I just want to be able to get row number from the name row... like if pix is blah.jpg so it searches for blah.jpg in name column in db, then determines which row it is in (like 3rd row) so I can use that for 3 out of 100 images (which I can do with mysql_num_rows(); function).. I just need to know what row it is in... but I think the easiest way is to use ids.

Unless you have another idea.
Posted: Wed Oct 19, 2005 6:21 pm
by newmember
because so people can nagivate my viewing page easily
you can read about SQL_CALC_FOUND_ROWS
here
use this together with LIMIT clause.
SQL_CALC_FOUND_ROWS will enable you to know how many records there are total and LIMIT selects only specific range/record
there are probably other way too...
and possibly be able to memorize the url easier rather than having view.php?offset=1
do you think there are peolpe who memorize links?

Posted: Wed Oct 19, 2005 9:04 pm
by Dm7
newmember wrote:because so people can nagivate my viewing page easily
you can read about SQL_CALC_FOUND_ROWS
here
use this together with LIMIT clause.
SQL_CALC_FOUND_ROWS will enable you to know how many records there are total and LIMIT selects only specific range/record
there are probably other way too...
and possibly be able to memorize the url easier rather than having view.php?offset=1
do you think there are peolpe who memorize links?

Argh I'm stupid.

I dont understand how it works...and how can i use LIMIT clause when I use WHERE clause to get what I want. care to give me some examples?
And uh.. I do memorize links.
Okay... I connected to db, etc. and my code is...
Code: Select all
// BETA VERSION!!!
$sqltest = "SELECT SQL_CALC_FOUND_ROWS(name) FROM $table WHERE name ='$pix'";
$results3 = mysql_query($sqltest);
$test = mysql_fetch_array($results3) or die ("Error ". mysql_error());
echo $test[0];
$test returned as name. I want row. :S
Posted: Fri Oct 21, 2005 6:28 pm
by Dm7
I still cannot figure out how to get returned number for a row? Can somebody help me out please?
Posted: Fri Oct 21, 2005 6:57 pm
by Charles256
assuming i understand your problem correctly..you could do the following...
show the first blurgem(blurgem being how many results they requested) by using a limit statement.and then on page two use this nifty function..
http://us2.php.net/mysql_data_seek
along with the proper modifier to start at said row along with result..and then using some nifty URL manipulation you should be able to accomplish what you were asking..you're welcome;)