Foros del Web » Programando para Internet » PHP »

sitio estilo groupon

Estas en el tema de sitio estilo groupon en el foro de PHP en Foros del Web. hola estoy realizando una web estilo groupon. pero desde cero, no es clon ni mucho menos.. es en la dinamica se podria decir parecida nada ...
  #1 (permalink)  
Antiguo 05/11/2012, 12:20
 
Fecha de Ingreso: marzo-2011
Mensajes: 115
Antigüedad: 13 años, 1 mes
Puntos: 0
sitio estilo groupon

hola estoy realizando una web estilo groupon.
pero desde cero, no es clon ni mucho menos.. es en la dinamica se podria decir parecida nada más..

lo que no consigo es poder crear el reloj cuenta atras como en [URL="http://www.groupon.com.uy"]http://www.groupon.com.uy[/URL]

si alguien me puede orientar o ayudar muy agradecido..

la pagina es en php mysql

el formulario sube bien los datos que le proporcionan los usuarios

Código MySQL:
Ver original
  1. CREATE TABLE IF NOT EXISTS `ofertas` (
  2.   `id_ofertas` int(11) NOT NULL AUTO_INCREMENT,
  3.   `Titulo` varchar(100) COLLATE utf16_spanish_ci DEFAULT NULL,
  4.   `Descripcion` varchar(255) COLLATE utf16_spanish_ci DEFAULT NULL,
  5.   `imagen0` varchar(255) COLLATE utf16_spanish_ci DEFAULT NULL,
  6.   `imagen1` varchar(255) COLLATE utf16_spanish_ci DEFAULT NULL,
  7.   `imagen2` varchar(255) COLLATE utf16_spanish_ci DEFAULT NULL,
  8.   `imagen3` varchar(255) COLLATE utf16_spanish_ci DEFAULT NULL,
  9.   `id_usuario` int(11) NOT NULL,
  10.   `Precio` varchar(100) COLLATE utf16_spanish_ci DEFAULT NULL,
  11.   `Antes` varchar(100) COLLATE utf16_spanish_ci DEFAULT NULL,
  12.   `Cantidad` int(100) DEFAULT NULL,
  13.   PRIMARY KEY (`id_ofertas`)
  14. ) ENGINE=InnoDB  DEFAULT CHARSET=utf16 COLLATE=utf16_spanish_ci AUTO_INCREMENT=3 ;

los datos se guardan bien, lo que no me doy cuenta o no se es luego como hacer para mostrar la hora en que termina esa oferta?

pido disculpas y doy las gracias al que me pueda orientar aunque sea
ya eh buscado en el santo google pero nada!!!
  #2 (permalink)  
Antiguo 05/11/2012, 12:30
Avatar de Patriarka  
Fecha de Ingreso: enero-2011
Ubicación: Moreno, Buenos Aires, Argentina
Mensajes: 2.851
Antigüedad: 13 años, 3 meses
Puntos: 288
Respuesta: sitio estilo groupon

primero traer la hora actual y validar si la oferta esta vigente.
si la oferta esta vigente calcular el tiempo restante,
mostrar ese tiempo como inicial para el usuario que ingresa al sistema.

luego el reloj lo tenes que hacer por ajax (para mantener la hora del servidor)
cada segundo hacer una llamada de ajax con el mismo camculo anterior y actualizar el reloj html
con javascript

re facil!
  #3 (permalink)  
Antiguo 05/11/2012, 12:31
 
Fecha de Ingreso: abril-2009
Ubicación: en un lugar de la mancha
Mensajes: 236
Antigüedad: 15 años
Puntos: 38
Respuesta: sitio estilo groupon

Javascript
aki tienes varios ejemplos

http://www.ajaxshake.com/es/JS/12141/relojes.html

espero te ayude, buena suerte
  #4 (permalink)  
Antiguo 05/11/2012, 12:33
Avatar de webseficientes  
Fecha de Ingreso: enero-2005
Ubicación: Buenos Aires, Argentina
Mensajes: 320
Antigüedad: 19 años, 3 meses
Puntos: 14
Respuesta: sitio estilo groupon

Tendrías que traer la hora correspondiente con Php (cada vez que llamas a la pagina y traes todos los datos de una promoción)

y luego mediante Javascript, solo javascript actualizas el tiempo restante, mediante una función que se llama cada segundo y actualiza el reloj.

Espero haberte orientado.

Gerardo.
__________________
Gerardo Benitez
Programador Web Freelance, SEO, Diseño web
  #5 (permalink)  
Antiguo 05/11/2012, 14:13
 
Fecha de Ingreso: marzo-2011
Mensajes: 115
Antigüedad: 13 años, 1 mes
Puntos: 0
Respuesta: sitio estilo groupon

alguna otra orientacion? necesito ayuda....
  #6 (permalink)  
Antiguo 05/11/2012, 15:12
Avatar de Patriarka  
Fecha de Ingreso: enero-2011
Ubicación: Moreno, Buenos Aires, Argentina
Mensajes: 2.851
Antigüedad: 13 años, 3 meses
Puntos: 288
Respuesta: sitio estilo groupon

si no lees y haces los ejemplos que te indicamos vas a estar siempre en la misma,
la solucion magica no existe solo esta en vos

saludos
  #7 (permalink)  
Antiguo 05/11/2012, 15:41
Avatar de dvbeaumont  
Fecha de Ingreso: marzo-2011
Ubicación: Caracas
Mensajes: 145
Antigüedad: 13 años, 1 mes
Puntos: 1
Respuesta: sitio estilo groupon

Yo te recomiendo lo compres u.u son funcionales y tienes la base del sistema. De allí podrías partir a lo que deseas.

Inviertes menos tiempo y mejoras el trabajo
__________________
Sé parte de nuestro mundo creativo.

http://bbcreativos.com
  #8 (permalink)  
Antiguo 06/11/2012, 17:52
 
Fecha de Ingreso: marzo-2011
Mensajes: 115
Antigüedad: 13 años, 1 mes
Puntos: 0
Respuesta: sitio estilo groupon

ya logre que las dos fechas se guarden en la base de datos un poco de jquery y php ahora como hago para

saber la diferencia entre la hora de creado el articulo y de finalizado? osea la hora que el usuario quiera que finalice?

como hago esa cuenta regresiva?

ayuda pliss
  #9 (permalink)  
Antiguo 06/11/2012, 18:01
 
Fecha de Ingreso: abril-2009
Ubicación: en un lugar de la mancha
Mensajes: 236
Antigüedad: 15 años
Puntos: 38
Respuesta: sitio estilo groupon

Buca trabajo con fechas en javascript

http://digitta.com/2008/03/datejs-li...on-fechas.html
http://avlprogrammer.blogspot.com/20...t-parte-1.html
http://www.programacionweb.net/artic...ticulo/?num=60
http://www.yukei.net/2010/06/trabaja...en-javascript/
http://www.geekzone.com.ar/content/t...-en-javascript
  #10 (permalink)  
Antiguo 07/11/2012, 05:45
 
Fecha de Ingreso: marzo-2011
Mensajes: 115
Antigüedad: 13 años, 1 mes
Puntos: 0
Respuesta: sitio estilo groupon

Hola haber si voy por buen o mal camino ? tengo este script
Código PHP:
Ver original
  1. <?php require('/Connections/hoysale.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6.   if (PHP_VERSION < 6) {
  7.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8.   }
  9.  
  10.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  11.  
  12.   switch ($theType) {
  13.     case "text":
  14.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  15.       break;    
  16.     case "long":
  17.     case "int":
  18.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  19.       break;
  20.     case "double":
  21.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  22.       break;
  23.     case "date":
  24.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  25.       break;
  26.     case "defined":
  27.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  28.       break;
  29.   }
  30.   return $theValue;
  31. }
  32. }
  33.  
  34. $maxRows_ofertas = 10;
  35. $pageNum_ofertas = 0;
  36. if (isset($_GET['pageNum_ofertas'])) {
  37.   $pageNum_ofertas = $_GET['pageNum_ofertas'];
  38. }
  39. $startRow_ofertas = $pageNum_ofertas * $maxRows_ofertas;
  40.  
  41. mysql_select_db($database_hoysale, $hoysale);
  42. $query_ofertas = "SELECT DATEDIFF ( ofertas.fecha_de_cierre, ofertas.fecha_de_inicio) FROM ofertas";
  43. $query_limit_ofertas = sprintf("%s LIMIT %d, %d", $query_ofertas, $startRow_ofertas, $maxRows_ofertas);
  44. $ofertas = mysql_query($query_limit_ofertas, $hoysale) or die(mysql_error());
  45. $row_ofertas = mysql_fetch_assoc($ofertas);
  46.  
  47. if (isset($_GET['totalRows_ofertas'])) {
  48.   $totalRows_ofertas = $_GET['totalRows_ofertas'];
  49. } else {
  50.   $all_ofertas = mysql_query($query_ofertas);
  51.   $totalRows_ofertas = mysql_num_rows($all_ofertas);
  52. }
  53. $totalPages_ofertas = ceil($totalRows_ofertas/$maxRows_ofertas)-1;
  54.  
  55.  
  56. ?>
  57. <table border="1">
  58.   <tr>
  59.     <td>DATEDIFF (ofertas.fecha_de_inicio</td>
  60.     <td>int</td>
  61.   </tr>
  62.   <?php do { ?>
  63.     <tr>
  64.       <td><?php echo $row_ofertas['DATEDIFF (ofertas.fecha_de_cierre']; ?></td>
  65.       <td><?php echo $row_ofertas['int']; ?></td>
  66.     </tr>
  67.     <?php } while ($row_ofertas = mysql_fetch_assoc($ofertas));?>
  68.  
  69.  
  70. </table>

por ahora no sale lo deseado, me da este error :
Código HTML:
Ver original
  1. Warning: mysql_fetch_assoc(): 4 is not a valid MySQL result resource in C:\xampp\htdocs\Untitled-1.php on line 68
  2. ;
  3. DATEDIFF (ofertas.fecha_de_inicio   int
  4.  
  5. Notice: Undefined index: DATEDIFF (ofertas.fecha_de_cierre in C:\xampp\htdocs\Untitled-1.php on line 65
  6.    
  7. Notice: Undefined index: int in C:\xampp\htdocs\Untitled-1.php on line 66
  #11 (permalink)  
Antiguo 07/11/2012, 09:28
 
Fecha de Ingreso: marzo-2011
Mensajes: 115
Antigüedad: 13 años, 1 mes
Puntos: 0
Respuesta: sitio estilo groupon

ahora logre que me diga esta subasta termina en xxxx :

este es el script :
Código PHP:
Ver original
  1. <?php require('/Connections/hoysale.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6.   if (PHP_VERSION < 6) {
  7.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8.   }
  9.  
  10.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  11.  
  12.   switch ($theType) {
  13.     case "text":
  14.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  15.       break;    
  16.     case "long":
  17.     case "int":
  18.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  19.       break;
  20.     case "double":
  21.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  22.       break;
  23.     case "date":
  24.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  25.       break;
  26.     case "defined":
  27.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  28.       break;
  29.   }
  30.   return $theValue;
  31. }
  32. }
  33.  
  34. $maxRows_ofertas = 3;
  35. $pageNum_ofertas = 0;
  36. if (isset($_GET['pageNum_ofertas'])) {
  37.   $pageNum_ofertas = $_GET['pageNum_ofertas'];
  38. }
  39. $startRow_ofertas = $pageNum_ofertas * $maxRows_ofertas;
  40.  
  41. mysql_select_db($database_hoysale, $hoysale);
  42. $query_ofertas = "SELECT * FROM ofertas";
  43. $query_limit_ofertas = sprintf("%s LIMIT %d, %d", $query_ofertas, $startRow_ofertas, $maxRows_ofertas);
  44. $ofertas = mysql_query($query_limit_ofertas, $hoysale) or die(mysql_error());
  45. $row_ofertas = mysql_fetch_assoc($ofertas);
  46.  
  47. if (isset($_GET['totalRows_ofertas'])) {
  48.   $totalRows_ofertas = $_GET['totalRows_ofertas'];
  49. } else {
  50.   $all_ofertas = mysql_query($query_ofertas);
  51.   $totalRows_ofertas = mysql_num_rows($all_ofertas);
  52. }
  53. $totalPages_ofertas = ceil($totalRows_ofertas/$maxRows_ofertas)-1;
  54.  
  55.  
  56. $target_time = mktime ('08:47:35');
  57.  
  58. $current_time = time();
  59.  
  60. $difference = ($target_time -$current_time);
  61.  
  62. $time = (int) ($difference/$row_ofertas['fecha_de_cierre']);
  63.  
  64. print "esta subasta termina en  '$time' horas";
  65.  
  66.  
  67. ?>
  68.  
  69. <table border="1">
  70.   <tr>
  71.     <td>fecha_de_inicio</td>
  72.     <td>fecha_de_cierre</td>
  73.   </tr>
  74.   <?php do { ?>
  75.     <tr>
  76.       <td><?php echo $row_ofertas['fecha_de_inicio']; ?></td>
  77.       <td><?php echo $row_ofertas['fecha_de_cierre']; ?></td>
  78.     </tr>
  79. </table>
  80.     <?php } while ($row_ofertas = mysql_fetch_assoc($ofertas)); ?>

me salen estos dos errores :
Código PHP:
Ver original
  1. Notice: A non well formed numeric value encountered in C:\xampp\htdocs\Untitled-1.php on line 56
  2. esta subasta termina en '-2880' horas
  3. fecha_de_inicio     fecha_de_cierre
  4. 2012-11-07 08:47:35     10/11/2012 23:59
  5.  
  6. Warning: mysql_fetch_assoc(): 4 is not a valid MySQL result resource in C:\xampp\htdocs\Untitled-1.php on line 81
  #12 (permalink)  
Antiguo 07/11/2012, 09:41
 
Fecha de Ingreso: marzo-2011
Mensajes: 115
Antigüedad: 13 años, 1 mes
Puntos: 0
Respuesta: sitio estilo groupon

ahora ya no me aparecen los errores, arregle esta parte

HIGHLIGHT="PHP"]

$target_time = mktime (00,00,00,01,01,2012); AQUI PUSE LA FECHA YO, PERO LO QUE QUISIERA ES QUE LA FECHA SALIERA DE LA BASE DE DATOS?

$current_time = time();

$difference = ($target_time -$current_time);

$time = (int) ($difference/$row_ofertas['fecha_de_cierre']);
$days = floor ($difference/86400);
print "esta subasta termina en '$time' horas";
[/HIGHLIGHT]
  #13 (permalink)  
Antiguo 07/11/2012, 09:48
 
Fecha de Ingreso: marzo-2011
Mensajes: 115
Antigüedad: 13 años, 1 mes
Puntos: 0
Respuesta: sitio estilo groupon

ahora logre que sea por la hora de la base de datos pero me sale

Notice: Undefined variable: time in C:\xampp\htdocs\Untitled-1.php on line 56
esta subasta termina en '-28' horas


Código PHP:
Ver original
  1. $target_time = mktime ($time/$row_ofertas['fecha_de_inicio']);
  2.  
  3. $current_time = time();
  4.  
  5. $difference = ($target_time -$current_time);
  6.  
  7. $time = (int) ($difference/$row_ofertas['fecha_de_cierre']);
  8. print "esta subasta termina en  '$time' horas";

de a poco va a salir toy seguro

Etiquetas: estilo, formulario, groupon, mysql, usuarios
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 17:14.