Foros del Web » Programando para Internet » PHP »

como hacerlo??? parte uno

Estas en el tema de como hacerlo??? parte uno en el foro de PHP en Foros del Web. Hola a todos, hace poco me ayudaron a meter codigo php dentro de html, y me servio bastante, ahora me surgio otro problema, espero me ...
  #1 (permalink)  
Antiguo 02/06/2004, 10:54
 
Fecha de Ingreso: septiembre-2003
Ubicación: Cancun mexico
Mensajes: 50
Antigüedad: 20 años, 7 meses
Puntos: 0
Busqueda como hacerlo??? parte uno

Hola a todos, hace poco me ayudaron a meter codigo php dentro de html, y me servio bastante, ahora me surgio otro problema, espero me puedan ayudar.

mi intención es hacer una apliación sencilla para que estudiantes puedan ver sus calificaciones vía internet. La aplicación sin diseño ya quedo, lo que muestro es una misma hoja, cuando insertas la matricula y la fecha de nacimiento se llama así misma la hoja para cargar los datos. aqui les pongo el código:

Código PHP:
<html> 
<head> 
<title>Calificaciones de Licenciatura</title> 
</head> 
<body> 
<h4>Resumen</h4> 
<?php 
// se verifica si ha sido rellamda la hoja
if (!$_REQUEST['Submit']) 
{     
html_form(); }
 elseif (
$_REQUEST['Submit'] == "VerBoleta"
{     
select_cd(); }
include(
"conex.php");
$link=my_conn() { 
function 
html_form() { 
/* Calls Connection Function */ 
$conn my_conn(); 
/* Defines query */ 
$sql "SELECT DISTINCT grupos.mat FROM grupos;"
/* Passes query to database */ 
$result mysql_query($sql$conn); 
if (!
$result) { 
    echo(
"<p>Error performing query: " mysql_error() . "</p>"); 
    exit(); 

/* Outputs HTML form */ 
?> 
<p>Dame la Matricula y la fecha de Nacimiento -formato (dia/mes/año)- para proporcionar Calificaciones</p> 
<p>(Por ejemplo, 6 de Enero de 1978 seria "06011978")</p> 
<form name="cds" method="post" action="todo.php"> 
<input name="mat" type="text" id="mat" size="30" maxlength="50"></td>
<input name="dob" type="text" id="dob" size="30" maxlength="50"></td>
<input type="submit" name="Submit" value="VerBoleta" /> 
</form> 
<? 
/* Closes Connection to the MySQL server */ 
mysql_close ($conn); 

function 
select_cd() { 
?> 
<? 
$conn
=my_conn();
/* Defines the Active Database for the Connection */ 
if (!@mysql_select_db("Calificaciones"$conn)) {    
     echo 
"<p>There has been an error. This is the error message:</p>"
     echo 
"<p><strong>" mysql_error() . "</strong></p>"
     echo 
"Please Contact Your Systems Administrator with the details"

?>
<?php
/* Retrieves the dob to validate */ 
$sql "SELECT dianacimiento FROM Alumnos"
$sql .= " WHERE (Alumnos.matricula = '{$_POST['mat']}')";
$result mysql_query($sql$conn); 
if (!
$result) { 
  echo(
"<p>Error performing query: " mysql_error() . "</p>"); 
  exit(); 

$contador=0;
while (
$row mysql_fetch_array($resultMYSQL_ASSOC))
        {
         
$contador=$contador+1;
         
$temporal=$row['dianacimiento'];
        }
if ((
$contador <> 1) || ($temporal <> $_POST['dob'])) {
       echo(
"<p>No son compatibles las fechas</p>"); 
       
mysql_close ($conn);
       exit();     
}
?> 
<?
/* Sets the SQL Query for the ALUMNOS Table */ 
$sql "SELECT * FROM Alumnos"
$sql .= " WHERE (Alumnos.matricula = '{$_POST['mat']}')"
/* Passes a Query to the Active Database for the ALUMNOS Table */ 
$result mysql_query($sql$conn); 
if (!
$result) { 
  echo(
"<p>Error performing query: " mysql_error() . "</p>"); 
  exit(); 

/* Starts the table and creates headings for the ALUMNOS Table */ 
?> 
<table border="1">
  <tr> 
    <td><font size="2" face="verdana"><strong>Matricula<img src="spacer.gif" width="10" height="1"></strong></font></td>
    <td><font size="2" face="verdana"><strong>Nombre<img src="spacer.gif" width="10" height="1"></strong></font></td>
    <td><font size="2" face="verdana"><strong>Carrera<img src="spacer.gif" width="10" height="1"></strong></font></td>
    <td><font size="2" face="verdana"><strong>Semestre<img src="spacer.gif" width="10" height="1"></strong></font></td>
  </tr>
  <? 
/* Retrieves the rows from the query result set 
and puts them into a HTML table row  for the ALUMNOS Table*/ 
while ($row mysql_fetch_array($resultMYSQL_ASSOC)) { 
    echo(
"<tr>\n<td align=\"center\"> <font size=\"1\" face=\"verdana\">" $row["Matricula"] . "</font></td>"); 
    echo(
"<td font size=\"1\" face=\"verdana\">" $row["Nombre"] . "</font></td>"); 
    echo(
"<td>" $row["Carrera"] . "</td>"); 
    echo(
"<td>" $row["Semestre"] . "</td>"); 
}
/* Closes the table */ 
?>
</table> 
<?
/* Sets the SQL Query for the DETALLE Table */ 
$sql "SELECT * FROM Detalle"
$sql .= " WHERE (Detalle.matr = '{$_POST['mat']}')"
/* Passes a Query to the Active Database for the DETALLE Table */ 
$result mysql_query($sql$conn); 
if (!
$result) { 
  echo(
"<p>Error performing query: " mysql_error() . "</p>"); 
  exit(); 

/* Starts the table and creates headings for the DETALLE Table */ 
?> 
<table> 
<tr> 
<td><strong>Clave</strong></td> 
<td><strong>Nombre</strong></td> 
<td><strong>Calificacion</strong></td> 
<td><strong>Promedio de Grupo</strong></td> 
<td><strong>Grupo</strong></td> 
<td><strong>Calif Extraord</strong></td> 
<td></td> 
</tr> 
<? 
/* Retrieves the rows from the query result set 
and puts them into a HTML table row  for the DETALLE Table*/ 
while ($row mysql_fetch_array($resultMYSQL_ASSOC)) { 

    echo(
"<tr>\n<td>" $row["Clave"] . "</td>"); 
    echo(
"<td>" $row["Nombre"] . "</td>"); 
    echo(
"<td>" $row["Calif"] . "</td>"); 
    echo(
"<td>" $row["Promgrupo"] . "</td>"); 
    echo(
"<td>" $row["Grupo"] . "</td>"); 
    echo(
"<td>" $row["Ext"] . "</td>"); 
}
/* Closes the table */ 
?> 
</table> 
<?
/* Sets the SQL Query for GRUPOS */ 
$sql "SELECT * FROM grupos"
$sql .= " WHERE (grupos.mat = '{$_POST['mat']}')"
/* Passes a Query to the Active Database for GRUPOS */ 
$result mysql_query($sql$conn); 
if (!
$result) { 
  echo(
"<p>Error performing query: " mysql_error() . "</p>"); 
  exit(); 

/* Starts the table and creates headings for GRUPOS */ 
?> 
<table> 
<tr> 
<td><strong>Grupo</strong></td> 
<td><strong>Promedio</strong></td> 
<td><strong>Lugar Ocupado</strong></td> 
<td><strong># de Lugares</strong></td> 
<td></td> 
</tr> 
<? 
/* Retrieves the rows from the query result set 
and puts them into a HTML table row for GRUPOS*/ 
while ($row mysql_fetch_array($resultMYSQL_ASSOC)) { 
    echo(
"<tr>\n<td>" $row["gpo"] . "</td>"); 
    echo(
"<td>" $row["promedio"] . "</td>"); 
    echo(
"<td>" $row["lugar"] . "</td>"); 
    echo(
"<td>" $row["numlugares"] . "</td>"); 
}
/* Closes the table */ 
?> 
</table> 
<? 
/* Closes Connection to the MySQL server */ 
mysql_close ($conn); 

?> 
</body> 
</html>
Hasta esta parte todo es lindo y maravilloso, pero ahora necesito darle la presentación necesaria y protocolaria de la escuela, osea insertar este codigo con más codigo html, lo he intentado pero aun me sigue dando errores, por ahora cuando meto las primeras lineas de codigo por ejemplo el IF que valida si se esta cargando o fue llamada me arroja error de:

Parse error: parse error, unexpected $ in /var/www/virtual/ulsacancun/php/boleta2.php on line 144

y la linea 144 ya es el final, en otro post de tema les pondre el codigo de la hoja ya con codigo para que se vea bonita...

Última edición por Cluster; 02/06/2004 a las 12:24
  #2 (permalink)  
Antiguo 02/06/2004, 10:55
 
Fecha de Ingreso: septiembre-2003
Ubicación: Cancun mexico
Mensajes: 50
Antigüedad: 20 años, 7 meses
Puntos: 0
Busqueda como hacerlo??? parte dos

código de web bonita:

Código PHP:
<html>
<head>
<title>&deg;&deg; Universidad La Salle Cancun &deg;&deg;</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- Fireworks MX Dreamweaver MX target.  Created Mon Apr 19 10:16:30 GMT-0600 (Hora estándar de México) 2004-->
<link href="estilos.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#ffffff" link="#0000CC" vlink="#0000CC" alink="#0000CC" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<?php
// se verifica si ha sido rellamda la hoja
if (!$_REQUEST['Submit']) 
{     
html_form(); }
 elseif (
$_REQUEST['Submit'] == "VerBoleta"
{     
select_cd(); }
include(
"conex.php");
$link=my_conn() { 
function 
html_form() { 
/* Calls Connection Function */ 
$conn my_conn(); 
/* Defines query */ 
$sql "SELECT DISTINCT grupos.mat FROM grupos;"
/* Passes query to database */ 
$result mysql_query($sql$conn); 
if (!
$result) { 
    echo(
"<p>Error performing query: " mysql_error() . "</p>"); 
    exit(); 

/* Outputs HTML form */ 
echo "<table width=\"761\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"textosverdana\">
  <!--DWLayoutTable-->
  <!-- fwtable fwsrc=\"nuevo2.png\" fwbase=\"nuevo.jpg\" fwstyle=\"Dreamweaver\" fwdocid = \"742308039\" fwnested=\"1\" -->
  <tr> 
    <td width=\"154\" rowspan=\"3\" valign=\"top\"><img name=\"nuevo_r1_c1\" src=\"images de fondo/nuevo_r1_c1.jpg\" width=\"154\" height=\"85\" border=\"0\" alt=\"\"></td>
    <td height=\"37\" colspan=\"2\" valign=\"top\"><img src=\"images%20de%20fondo/nuevo_r1_c2.jpg\" width=\"283\" height=\"37\"></td>
    <td width=\"166\" valign=\"top\"><img src=\"images%20de%20fondo/nuevo_r1_c4.jpg\" width=\"166\" height=\"37\"></td>
    <td width=\"157\" valign=\"top\"><img src=\"images%20de%20fondo/nuevo_r1_c5.jpg\" width=\"157\" height=\"37\"></td>
    <td width=\"1\"></td>
  </tr>
  <tr> 
    <td height=\"28\" colspan=\"2\" valign=\"top\"><img src=\"images%20de%20fondo/nuevo_r2_c2.jpg\" width=\"283\" height=\"28\"></td>
    <td valign=\"top\"><img src=\"images%20de%20fondo/nuevo_r2_c4.jpg\" width=\"166\" height=\"28\"></td>
    <td valign=\"top\"><img src=\"images%20de%20fondo/nuevo_r2_c5.jpg\" width=\"157\" height=\"28\"></td>
    <td></td>
  </tr>
  <tr> 
    <td height=\"20\" colspan=\"2\" valign=\"top\"><img src=\"images%20de%20fondo/nuevo_r3_c2.jpg\" width=\"283\" height=\"20\"></td>
    <td valign=\"top\"><img src=\"images%20de%20fondo/nuevo_r3_c4.jpg\" width=\"166\" height=\"20\"></td>
    <td valign=\"top\"><img src=\"images%20de%20fondo/nuevo_r3_c5.jpg\" width=\"157\" height=\"20\"></td>
    <td></td>
  </tr>
  <tr> 
    <td rowspan=\"4\" valign=\"top\"><img src=\"images%20de%20fondo/nuevo_r4_c1.jpg\" width=\"154\" height=\"85\"></td>
    <td height=\"24\" colspan=\"2\" valign=\"top\"><img src=\"images%20de%20fondo/nuevo_r4_c2.jpg\" width=\"283\" height=\"24\"></td>
    <td colspan=\"2\" valign=\"top\" class=\"fondoazul\"><!--DWLayoutEmptyCell-->&nbsp;</td>
    <td></td>
  </tr>
  <tr> 
    <td width=\"157\" rowspan=\"4\" valign=\"top\"><img src=\"images%20de%20fondo/nuevo_r5_c2%20admisiones.jpg\" width=\"157\" height=\"87\"></td>
    <td height=\"36\" colspan=\"3\" align=\"center\" valign=\"middle\">Boleta de Calificaciones</td>
    <td></td>
  </tr>
  <tr> 
    <td height=\"10\" colspan=\"3\" valign=\"top\"><img src=\"images%20de%20fondo/nuevo_r6_c3.jpg\" width=\"449\" height=\"10\"></td>
    <td></td>
  </tr>
  <tr> 
    <td colspan=\"3\" rowspan=\"5\" valign=\"top\"><p>Dame la Matricula y la fecha de 
        Nacimiento -formato (dia/mes/año)- para proporcionar Calificaciones</p>
      <p>(Por ejemplo, 6 de Enero de 1978 seria \"06011978\")</p></td>
    <td height=\"15\"></td>
  </tr>
  <tr> 
    <td rowspan=\"2\" valign=\"top\"><img src=\"images%20de%20fondo/nuevo_r8_c1.jpg\" width=\"154\" height=\"56\"></td>
    <td height=\"26\"></td>
  </tr>
  <tr> 
    <td rowspan=\"2\" valign=\"top\"><img src=\"images%20de%20fondo/nuevo_r9_c2.jpg\" width=\"157\" height=\"74\"></td>
    <td height=\"30\"></td>
  </tr>
  <tr> 
    <td rowspan=\"4\" valign=\"top\" class=\"fondoazul\"><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"154\" height=\"485\">
        <param name=\"movie\" value=\"menuvertical.swf\">
        <param name=\"quality\" value=\"high\">
        <embed src=\"menuvertical.swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"154\" height=\"485\"></embed></object></td>
    <td height=\"44\"></td>
  </tr>
  <tr> 
    <td height=\"82\" valign=\"top\"><img src=\"images%20de%20fondo/nuevo_r11_c2.jpg\" width=\"157\" height=\"82\"></td>
    <td></td>
  </tr>
  <tr> 
    <td height=\"105\" colspan=\"4\" valign=\"top\">"
;
    echo 

    <form name=\"cds\" method=\"post\" action=\"boleta2.php\">
        <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"textosverdana\">
          <!--DWLayoutTable-->
          <tr> 
            <td width=\"64\" rowspan=\"3\" valign=\"top\"><!--DWLayoutEmptyCell-->&nbsp;</td>
            <td width=\"200\" height=\"25\" valign=\"middle\">Escribe tu matricula:</td>
            <td width=\"48\" rowspan=\"2\" valign=\"top\"><!--DWLayoutEmptyCell-->&nbsp;</td>
            <td width=\"208\" valign=\"top\"><input name=\"mat\" type=\"text\" id=\"mat\" size=\"20\" maxlength=\"10\"></td>
            <td width=\"86\" rowspan=\"2\" valign=\"top\"><!--DWLayoutEmptyCell-->&nbsp;</td>
          </tr>
          <tr> 
            <td height=\"28\" valign=\"middle\">Escribe tu fecha de Nacimiento:</td>
            <td valign=\"top\"><input name=\"dob\" type=\"text\" id=\"dob\" size=\"20\" maxlength=\"10\"></td>
          </tr>
          <tr> 
            <td height=\"16\" colspan=\"4\" valign=\"top\"><div align=\"center\"><br>
                <br>
                <input type=\"submit\" name=\"Submit\" value=\"VerBoleta\">
              </div></td>
          </tr>
        </table>
      </form></td>
    <td></td>
  </tr>
  <tr> 
    <td height=\"330\" colspan=\"4\" valign=\"top\"><!--DWLayoutEmptyCell-->&nbsp;</td>
    <td></td>
  </tr>
  <tr> 
    <td height=\"0\"></td>
    <td></td>
    <td width=\"126\"></td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
</table>"
;
?>
</body>
</html>
Por favor alguien ayudeme, en serio que ya intentado meter en varias partes el código ya e verificado las etiquetas y no me queda, por favor alguien que sepa cual es mi error.

Se los agradecere eternamente.

Última edición por Cluster; 02/06/2004 a las 12:26
  #3 (permalink)  
Antiguo 02/06/2004, 12:37
O_O
 
Fecha de Ingreso: enero-2002
Ubicación: Santiago - Chile
Mensajes: 34.417
Antigüedad: 22 años, 3 meses
Puntos: 129
Intenta no poner dos mensajes diferentes que guardan cierta relación como es este caso .. así se pierde el hilo del mensaje. Para otra vez .. puedes publicar tu "parte uno" y entras a tu mismo mensaje para responderte con la "parte X" que necesites ..

Recuerda también que hay un botón para marcar el código y que quede como lo ves para mejor lectura.

Un saludo,
  #4 (permalink)  
Antiguo 02/06/2004, 13:21
Ex Colaborador
 
Fecha de Ingreso: junio-2002
Mensajes: 9.091
Antigüedad: 21 años, 10 meses
Puntos: 16
Hola,

Yo prefiero no meter un tocho codigo de HTML dentro de un echo. Hay muchas posibilidades de liarte con la comillas. Si tienes un codigo HTML muy grande, con variables PHP dentro, usa :
Código PHP:
<div name="nombre">aqui HTml con variables <?php echo $variable?> PHP y las comillas " que quiereas</div>
o la sintaxis HEREDOC:
Código PHP:
echo <<< HTML
<div name="nombre">aqui HTml con variables $variable PHP y las comillas " que quiereas</div>
HTML; 
Mas info: http://www.php.net/manual/en/language.types.string.php

Saludos.
__________________
Josemi

Aprendiz de mucho, maestro de poco.
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 07:01.