I am trying to make a webpage using php & sql using Dreamweaver. I have no coding experience in web development.
I have made a page which displays search results from database. Now this result which comes up is to be placed in a URL & the only way I have thought that this can be done is if I am able to store the search result in a variable & concatenate it in the URL. But I am unable to do so as I have no idea how to pass the search result which comes up.
Thanks
<?php require_once('Connections/check_mag.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$name_Recordset1 = 12;
$name_Recordset1 = $_GET['searchinput'];
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
$colname_Recordset1 = "-1";
if (isset($_GET['searchinput'])) {
$colname_Recordset1 = $_GET['searchinput'];
}
mysql_select_db($database_check_mag, $check_mag);
$query_Recordset1 = sprintf("SELECT * FROM consignments WHERE `reference no` = %s", GetSQLValueString($colname_Recordset1, "text"));
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $check_mag) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<table border="1">
<tr>
<td>date</td>
<td>tracking no</td>
<td>reference no</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['date']; ?></td>
<td><?php echo $row_Recordset1['tracking no']; ?></td>
<td><?php echo $row_Recordset1['reference no']; ?></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
<p> </p>
<a href="http://mywebsite.com/page?name=<?php echo $name_Recordset1; ?>"></a>
<?php
$trackingcode = $_GET["searchinput"];
echo $trackingcode;
$name = $_GET['tracking no'];
echo $name;
?>
<a href="http://www.xyz.com/content/in/en/express/tracking.shtml?brand=xyz&AWB=<?php echo $trackingcode ?>"><?php echo $trackingcode?></a>
<br/>
</body>
</html>