Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

Document Number Tracking System

Links for php scripts

Moderators: macek, egami, gesf

Document Number Tracking System

Postby twinkenny » Sun Sep 16, 2012 8:57 pm

Hello fellow programmers, is nice to find a peaceful and lovely place like this and i hope knowing you the more will bring us more blessings and Fulfillment. I need your help to help me figure out exactly what i was doing wrong. paste the code below this article this project, am just a newbie in the arena of PHP programming and is a bit confusing and is my Industrial Attachment project. The aims is to fetch the matching column from <form value> in mySQL Database table and display the corresponding row in HTML table format this is how far i can go please "what i get is database and table not exist"

<?php
session_start();
if(isset($_POST['submit']))
{
require_once('connection.php');
$search=$_POST['search'];
$min_length = 11;
// you can set minimum length of the query if you want

if(strlen($search) >= $min_length)
{ // if query length is more or equal minimum length then

$search = htmlspecialchars($search);
// changes characters used in html to their equivalents, for example: < to &gt;

$search = mysql_real_escape_string($search);
}
function fnValidateAlphanumeric($search)
{
return ctype_alnum ($search);
}
}
// makes sure nobody uses SQL injection
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Search</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
<form method="POST" name="" action="index.php">
<table width="332" border="0" align="center">
<tr>
<td width="265">
<td width="57">&nbsp;</td>
</tr>
<tr>
<td colspan="2">Name:
<input name="search" type="text">
<td colspan="2"><input type="submit" value="Submit" name='submit'></td>
</tr>
</table>
<?php
require_once('connection.php');
$query="SELECT cid, blnumber, vesnamevge, pofdischg, pofdischg, dateofdischg FROM trackrecord WHERE blnumer='$search'";
$result=mysql_query($query);
if(!$result)
{
echo mysql_error();
}
$num=mysql_numrows($result);

mysql_close();
?>
<table border="1" cellspacing="2" cellpadding="2">
<tr bgcolor="#6699CC" height=10px >
<td align="left"><font face="Arial, Helvetica, sans-serif">|Bill Number| </font></td>
<td><font face="Arial, Helvetica, sans-serif">|Vessel Voyage Name|</font></td>
<td><font face="Arial, Helvetica, sans-serif"></font>|Place of Discharge|</td>
<td><font face="Arial, Helvetica, sans-serif"></font>|Date of Discharge|</td>
<td><font face="Arial, Helvetica, sans-serif">|Updates|</font></td>
</tr>

<?php
$i=0;
while ($i < $num) {

$f1=mysql_result($result,$i,"cid");
$f2=mysql_result($result,$i,"blnumber");
$f3=mysql_result($result,$i,"vesnamevge");
$f4=mysql_result($result,$i,"pofdischg");
$f5=mysql_result($result,$i,"dateofdischg");
?>

<tr>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f5; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"></font></td>
</tr>

<?php
$i++;
}
?>
</form>
</body>
</html>

Save as connection.php

<?php
$mysql_hostname = "localhost";
$mysql_user = "root";
$mysql_password = "";
$mysql_database = "trackingsystem";
$prefix = "";
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Could not connect database");
mysql_select_db($mysql_database, $bd) or die("Could not select database");
?>

Thanks and God bless you
twinkenny
New php-forum User
New php-forum User
 
Posts: 1
Joined: Sun Sep 16, 2012 8:29 pm

Return to PHP Scripts

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.