View Full Version : Resolved show 4 latest registries from mysql
auriaks
11-04-2009, 10:40 PM
Hallo, I want to call and show 4 latest regitered accounts to my page. How I can seperate 4 latest from others? What php script must look like? Thanks :)
Can I see your database structure please? Thank you.
auriaks
11-05-2009, 08:11 PM
INSERT INTO infos (info, about, date, time, url) ...
You ment this??
james438
11-05-2009, 10:10 PM
The following should help you get started. This assumes that you have a database and table set up. Replace
host with host name
username with database username
password with database password
maincontent with your table name
ID with column names(s)
<?php
$conn=mysql_connect("host", "username", "password");
mysql_select_db("database_name",$conn) or die("Unable to select database");
$query = "SELECT ID FROM maincontent ORDER BY ID desc limit 0,3";
$result = mysql_query($query,$conn) or die ("Couldn't execute query.");
while ($list_info = mysql_fetch_array($result,MYSQL_ASSOC)) {
$tadaa= $list_info['ID'];$me.="pop $tadaa pop<br>";}
echo "$me";
?>
Yes, that is what I mean. Does date respresent the time the user registered? (can I see an example of date being used?)
james438
11-05-2009, 10:47 PM
doh, you're right Nile. He is using date and time. I really need to slow down and read the posts a little more carefully before I reply.
It seems to me that it would be best to use datetime as opposed to date and time. Then again I use two sets of time for my articles as well; one for the date the article was written and the second for the date last it was last updated.
Haha. Every one makes mistakes :p.
Just to clarify (for auriaks) when I said example, I meant an example of a value that might be inserted into the date column, like: dd-MM-yy. Or something like that.
auriaks
11-06-2009, 06:56 PM
OK, here is all I got - i created this table:
# create links table
$SQL = " CREATE TABLE culture (";
$SQL = $SQL . " id INT NOT NULL AUTO_INCREMENT, ";
$SQL = $SQL . " product VARCHAR(500), ";
$SQL = $SQL . " about VARCHAR(1000), ";
$SQL = $SQL . " date DATE, ";
$SQL = $SQL . " time TIME, ";
$SQL = $SQL . " url VARCHAR(1000),";
$SQL = $SQL . " PRIMARY KEY(id) );";
I use this script for registration:
//connect to the database
//select table
$date = date("Y-m-d");
$time = date("H:i:s");
$type = $_POST['type'];
if($_POST['product'] == '') {
$error .= "<li>None or same name</li>";
}
if($_POST['about'] == '') {
$error .= "<li>Insert your description</li>";
}
if($_POST['url'] == '') {
$error .= "<li>Insert Net</li>";
}
if(isset($_POST['submit'])) {
if(isset($error)) {
echo '<font color="#ff0000">Cant insert. Mistakes:';
echo '<ol>'.$error.'</ol></font>';
} else {
echo '<font color="Green">Inserted!</font>';
mysql_query("INSERT INTO $type (product, about, date, time, url)
VALUES('$_POST[product]', '$_POST[about]', '$date', '$time', '$_POST[url]')") or die(mysql_error());
}
}
?>
:) thx
Ok, give this a try:
Go into your PhpMyAdmin.
Click the database your table is in.
Click the table your information is in.
Click "Export"
Scroll down and click "Go"
Copy and paste all the information here in between [quote] tags.
Good luck.
auriaks
11-06-2009, 08:51 PM
-- phpMyAdmin SQL Dump
-- version 2.11.9.6
-- http://www.phpmyadmin.net
--
-- Darbinė stotis: localhost
-- Atlikimo laikas: 2009 m. Lapkričio 06 d. 22:48
-- Serverio versija: 5.0.85
-- PHP versija: 5.2.11
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- Duombazė: `buynsel`
--
-- --------------------------------------------------------
--
-- Sukurta duomenų struktūra lentelei `culture`
--
CREATE TABLE IF NOT EXISTS `culture` (
`id` int(11) NOT NULL auto_increment,
`product` varchar(1000) default NULL,
`about` varchar(1000) default NULL,
`date` date default NULL,
`time` time default NULL,
`url` varchar(1000) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;
--
-- Sukurta duomenų kopija lentelei `culture`
--
INSERT INTO `culture` (`id`, `product`, `about`, `date`, `time`, `url`) VALUES
(2, 'The Magic Of Making Up (Get Your Ex Back).', 'A Hungry Crowd That Is Desperate For Help Makes You A Lot Of Easy Sales. Help Keep Relationships Together And Make 75% Commission Too. Virtually Unlimited Traffic Now And In The Future. For Free Articles, Video And Help See Affiliate Page.', '2009-10-30', '20:01:27', 'http://aad7133cpxun0vb6mammlsuy9k.hop.clickbank.net/?tid=BUY'),
(3, 'Government-Records.com - **Pool Your Bonuses With Our Sites!', 'Over 200 Million Real Public Records And Growing! Promote The Highest Quality Public Records Service On Cb! Telephone Customer Support Coming Soon. Always Raising The Bar!', '2009-10-30', '20:02:07', 'http://ce6c8x9ep-ul7r3fzt32ec5yvm.hop.clickbank.net/?tid=BUY'),
(4, 'Home Made Energy - The Best Diy Offer!', 'Home Made Energy - The Best Diy Offer!', '2009-10-30', '20:02:52', 'http://e746936jsyxp8lbbtjkkf3n0ua.hop.clickbank.net/?tid=BUY'),
(5, 'Save My Marriage Today!', 'Save My Marriage Today!', '2009-10-31', '22:07:54', 'http://bcc83v4hx3tg8m6dpgfbnb45o3.hop.clickbank.net/?tid=BUY2');
lithuanian, but maybe you'll understand :)
Does ID represent the users ID?
auriaks
11-06-2009, 09:15 PM
id - is number (auto increment)
product - users nick (name)
about - About his website
url - his link
Ok, try this query:
SELECT * FROM `culture` ORDER BY `id` LIMIT 4
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.