pero tengo una dudota
tengo un script que me genera un programita (php generator form mysql ) siempre me havia funcionado pero ahora que necesito que sea un script mas complejono funciona
me pueden ayudar
GRACIAS
[/code]
<?php session_start();?> <html><head><title>aldebara_sugarcrm -- Avance</title><meta name="generator" http-equiv="content-type" content="text/html"><style type="text/css"> body { background-color: #FFFFFF; color: #000000; font-family: Arial; font-size: 12px; } .bd { background-color: #FFFFFF; color: #000000; font-family: Arial; font-size: 12px; } .tbl { background-color: #FFFFFF; } a:link { color: #FF0000; font-family: Arial; font-size: 12px; } a:active { color: #0000FF; font-family: Arial; font-size: 12px; } a:visited { color: #800080; font-family: Arial; font-size: 12px; } .hr { background-color: #000000; color: #FFFFFF; font-family: Arial; font-size: 12px; } a.hr:link { color: #FFFFFF; font-family: Arial; font-size: 12px; } a.hr:active { color: #FFFFFF; font-family: Arial; font-size: 12px; } a.hr:visited { color: #FFFFFF; font-family: Arial; font-size: 12px; } .dr { background-color: #FFFFFF; color: #000000; font-family: Arial; font-size: 12px; } .sr { background-color: #F3F3F3; color: #000000; font-family: Arial; font-size: 12px; }</style></head><body><h2>Reporte</h2></td></tr></table><?php $conn = connect(); $showrecs = 99; $pagerange = 99; $page = @$_GET["page"]; IF (!isset($page)) $page = 1; SELECT(); mysql_close($conn);?><TABLE class="bd" width="100%"><tr><td class="hr">arroyoj</td></tr></table></body></html> <?php FUNCTION SELECT() { global $a; global $showrecs; global $page; $res = sql_select(); #$count = sql_getrecordcount(); IF ($count % $showrecs != 0) { $pagecount = intval($count / $showrecs) + 1; } ELSE { $pagecount = intval($count / $showrecs); } $startrec = $showrecs * ($page - 1); IF ($startrec < $count) {mysql_data_seek($res, $startrec);} $reccount = MIN($showrecs * $page, $count);?><TABLE class="bd" border="0" cellspacing="1" cellpadding="4"><tr><td>TABLE: Avance</td></tr><tr><td>Records shown <?php echo $startrec + 1 ?> - <?php echo $reccount ?> OF <?php echo $count ?></td></tr></table><hr SIZE="1" noshade><?php showpagenav($page, $pagecount); ?>[br /]<TABLE class="tbl" border="1" cellspacing="1" cellpadding="5"width="100%"><tr></tr><?php FOR ($i = $startrec; $i < $reccount; $i++) { $row = mysql_fetch_assoc($res); $style = "dr"; IF ($i % 2 != 0) { $style = "sr"; }?><tr></tr><?php } mysql_free_result($res);?></table>[br /]<?php showpagenav($page, $pagecount); ?><?php } ?> <?php FUNCTION showpagenav($page, $pagecount){?><TABLE class="bd" border="0" cellspacing="1" cellpadding="4"><tr><?php IF ($page > 1) { ?><td><a href="Avance.php?page=<?php echo $page - 1 ?>"><< Prev </td><?php } ?><?php global $pagerange; IF ($pagecount > 1) { IF ($pagecount % $pagerange != 0) { $rangecount = intval($pagecount / $pagerange) + 1; } ELSE { $rangecount = intval($pagecount / $pagerange); } FOR ($i = 1; $i < $rangecount + 1; $i++) { $startpage = (($i - 1) * $pagerange) + 1; $count = MIN($i * $pagerange, $pagecount); IF ((($page >= $startpage) && ($page <= ($i * $pagerange)))) { FOR ($j = $startpage; $j < $count + 1; $j++) { IF ($j == $page) {?><td>[b]<?php echo $j ?>[/b]</td><?php } ELSE { ?><td><a href="Avance.php?page=<?php echo $j ?>"><?php echo $j ?></td><?php } } } ELSE { ?><td><a href="Avance.php?page=<?php echo $startpage ?>"><?php echo $startpage ."..." .$count ?></td><?php } } } ?><?php IF ($page < $pagecount) { ?><td> <a href="Avance.php?page=<?php echo $page + 1 ?>">Next >> </td><?php } ?></tr></table><?php } ?> <?php FUNCTION CONNECT(){ $conn = mysql_connect("HOST", "BASE", "PASS"); mysql_select_db("aldebara_sugarcrm"); RETURN $conn;} FUNCTION sql_select(){ global $conn; $sql = "SELECT * FROM (TRUNCATE TABLE wtareas ; insert into wtareas (parent_id, date_due) select parent_id, MAX(date_due)from tasks WHERE (parent_type = 'Accounts' AND deleted <> '1' and parent_id is not null) group by parent_id; select accounts_cstm.fase_c as 'Fase', accounts_cstm.status_c as 'Estatus cuenta', accounts.name as 'Cuenta', tasks.date_due as 'Vencimiento ultima tarea', DATEDIFF(now(),tasks.date_due) as 'Dias sin movimiento', CONCAT(users.first_name,' ',users.last_name) AS 'Asignado a', tasks.status as 'Estatus tarea', tasks.description as 'Descripcion' , accounts_cstm.demanda_c as 'Demanda', accounts_cstm.lote_demandas_c as 'Lote' FROM wtareas INNER JOIN tasks ON wtareas.parent_id = tasks.parent_id AND wtareas.date_due = tasks.date_due INNER JOIN accounts ON wtareas.parent_id = accounts.id INNER JOIN accounts_cstm ON wtareas.parent_id = accounts_cstm.id_c INNER JOIN users ON tasks.assigned_user_id = users.id WHERE (accounts_cstm.status_c <> 'Cancelado' and accounts_cstm.status_c <> 'Concluida') ORDER BY accounts_cstm.fase_c, accounts.name) subq"; $res = mysql_query($sql, $conn) OR die(mysql_error()); RETURN $res;} FUNCTION sql_getrecordcount(){ global $conn; $sql = "SELECT COUNT(*) FROM (TRUNCATE TABLE wtareas ; insert into wtareas (parent_id, date_due) select parent_id, MAX(date_due)from tasks WHERE (parent_type = 'Accounts' AND deleted <> '1' and parent_id is not null) group by parent_id; select accounts_cstm.fase_c as 'Fase', accounts_cstm.status_c as 'Estatus cuenta', accounts.name as 'Cuenta', tasks.date_due as 'Vencimiento ultima tarea', DATEDIFF(now(),tasks.date_due) as 'Dias sin movimiento', CONCAT(users.first_name,' ',users.last_name) AS 'Asignado a', tasks.status as 'Estatus tarea', tasks.description as 'Descripcion' , accounts_cstm.demanda_c as 'Demanda', accounts_cstm.lote_demandas_c as 'Lote' FROM wtareas INNER JOIN tasks ON wtareas.parent_id = tasks.parent_id AND wtareas.date_due = tasks.date_due INNER JOIN accounts ON wtareas.parent_id = accounts.id INNER JOIN accounts_cstm ON wtareas.parent_id = accounts_cstm.id_c INNER JOIN users ON tasks.assigned_user_id = users.id WHERE (accounts_cstm.status_c <> 'Cancelado' and accounts_cstm.status_c <> 'Concluida') ORDER BY accounts_cstm.fase_c, accounts.name) subq"; $res = mysql_query($sql, $conn) OR die(mysql_error()); $row = mysql_fetch_assoc($res); reset($row); RETURN CURRENT($row);} ?>