[Gllug] mySQL PHP

will will at hellacool.co.uk
Tue Jul 10 15:40:42 UTC 2001


----- Original Message -----
From: Jackson, Harry <HJackson at colt-telecom.com>
To: <gllug at linux.co.uk>
Sent: Tuesday, July 10, 2001 4:09 PM
Subject: [Gllug] mySQL PHP


> Hi all,
>
> For anyone who is interested this is the PHP page that I am using to
> generate the front page. It probably could be a lot neater but it works
> except on initial load because the "$var"  variables have not been
initiated
> and I am not sure how to initiate them only on refresh or first entry of
the
> page. I have tried to just declare them but they then always default to
that
> value when I hit the "Enter Information" button on the page.

You could simply put the last section in an if statement to test whether the
submit button had been pressed.  This will only do the database stuff if the
form has been submitted so the variables will have values:

if ($submit)
 {

 $db = mysql_connect("localhost");
 mysql_select_db("remedy_harry",$db);

 $caseid = mysql_query("SELECT * FROM remedy_base where $var1 Like '%$var2%'
 and $var3 $var4 '%$var5%'",$db);


 printf("<h1><b> The following is a list of Case ID's for Remedy:
 </b></h1><br><table border=1>");


 while ($myrow = mysql_fetch_row($caseid)) {

 $myrow[6] = eregi_replace("\n", "<br>", $myrow[6]);

 printf( "<tr><td>%s</td>  <td>%s</td>
      <td>%s</td>  <td>%s</td>
      <td>%s</td>  <td>%s</td>
      <td>%s</td>  <td>%s</td>
      <td>%s</td>  <td>%s</td>
 </tr>"
      , $myrow[0],  $myrow[1]
      , $myrow[2],  $myrow[3]
      , $myrow[4],  $myrow[5]
      , $myrow[6],  $myrow[7]
      , $myrow[7],  $myrow[8]
      , $myrow[9]
 );

 }
 echo "</table>\n";
}




-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list