Search Webmaster Help and Solution

Creating A Search Module from MySQL

Hello,

I am having issues creating a search module to get records from a database, by having a module that you choose the first date and the last date and it should generate all results between that date.

Please assist me.

My Table is as below:

http://i36.tinypic.com/33lc7id.png

And also i have made this script where it shows the records on a table for the whole table:

Quote: <?php
$username="root";
$password="";
$database="project";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM clientdata WHERE member_id=" . $_SESSION[SESS_FIRST_NAME] . " limit 1,5";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();
?>
<table border="1" cellspacing="2" cellpadding="2">
<tr>
<th><font face="Arial, Helvetica, sans-serif">Id</font></th>
<th><font face="Arial, Helvetica, sans-serif">Member Name</font></th>
<th><font face="Arial, Helvetica, sans-serif">Phone</font></th>
<th><font face="Arial, Helvetica, sans-serif">Time</font></th>
<th><font face="Arial, Helvetica, sans-serif">Prefix</font></th>
<th><font face="Arial, Helvetica, sans-serif">Total</font></th>

</tr>

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

$f1=mysql_result($result,$i,"id");
$f2=mysql_result($result,$i,"member_id");
$f3=mysql_result($result,$i,"Number");
$f4=mysql_result($result,$i,"Time");
$f5=mysql_result($result,$i,"Prefix");
$f6=mysql_result($result,$i,"Total");


?>

<tr>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td>
<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"><?php echo $f6; ?></font></td>

</tr>

<?php
$i++;
}
?>
Now i would like a script that has something like this.

I got this script from the net which i havent used but would like to implement it:

Quote: <?php
$mo=$_REQUEST[mo];
$yr=$_REQUEST[yr];
if (!isset($mo) || $mo<1 || $mo>12 || !is_numeric($mo)) $mo = date("m",time() - date(Z) + ($gmt * 3600));
if (!isset($yr) || $yr<1970 || $yr>2036 || !is_numeric($yr)) $yr = date("Y",time() - date(Z) + ($gmt * 3600));
?>
<form name="form3" method="post" action="<?php echo $PHP_SELF ?>">
<select name="mo" id="mo">
<?php
for ($N=1; $N<=12; $N++) {
echo "<option value=$N";
if ($N==$mo) echo " SELECTED";
echo ">$mth[$N]</option>";
}
?>
</select>
<select name="yr" id="yr">
<?php
for ($N=2000; $N<=2036; $N++) {
echo "<option";
if ($N==$yr) echo " SELECTED";
echo ">$N</option>";
}
?>
</select>
<input type="submit" name="Submit" value="Go">
</form> This is for the date selection, so therefore there would be two of these, the start date and the end date, that the client wants to view the data inside the database.

Please assist with the code, as i am not that good of a progammer.

Thanks & Regards Hello,

I am having issues creating a search module to get records from a database, by having a module that you choose the first date and the last date and it should generate all results between that date.

Please assist me.

My Table is as below:

http://i36.tinypic.com/33lc7id.png

And also i have made this script where it shows the records on a table for the whole table:

Quote: <?php
$username="root";
$password="";
$database="project";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM clientdata WHERE member_id=" . $_SESSION[SESS_FIRST_NAME] . " limit 1,5";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();
?>
<table border="1" cellspacing="2" cellpadding="2">
<tr>
<th><font face="Arial, Helvetica, sans-serif">Id</font></th>
<th><font face="Arial, Helvetica, sans-serif">Member Name</font></th>
<th><font face="Arial, Helvetica, sans-serif">Phone</font></th>
<th><font face="Arial, Helvetica, sans-serif">Time</font></th>
<th><font face="Arial, Helvetica, sans-serif">Prefix</font></th>
<th><font face="Arial, Helvetica, sans-serif">Total</font></th>

</tr>

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

$f1=mysql_result($result,$i,"id");
$f2=mysql_result($result,$i,"member_id");
$f3=mysql_result($result,$i,"Number");
$f4=mysql_result($result,$i,"Time");
$f5=mysql_result($result,$i,"Prefix");
$f6=mysql_result($result,$i,"Total");


?>

<tr>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td>
<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"><?php echo $f6; ?></font></td>

</tr>

<?php
$i++;
}
?>
Now i would like a script that has something like this.

I got this script from the net which i havent used but would like to implement it:

Quote: <?php
$mo=$_REQUEST[mo];
$yr=$_REQUEST[yr];
if (!isset($mo) || $mo<1 || $mo>12 || !is_numeric($mo)) $mo = date("m",time() - date(Z) + ($gmt * 3600));
if (!isset($yr) || $yr<1970 || $yr>2036 || !is_numeric($yr)) $yr = date("Y",time() - date(Z) + ($gmt * 3600));
?>
<form name="form3" method="post" action="<?php echo $PHP_SELF ?>">
<select name="mo" id="mo">
<?php
for ($N=1; $N<=12; $N++) {
echo "<option value=$N";
if ($N==$mo) echo " SELECTED";
echo ">$mth[$N]</option>";
}
?>
</select>
<select name="yr" id="yr">
<?php
for ($N=2000; $N<=2036; $N++) {
echo "<option";
if ($N==$yr) echo " SELECTED";
echo ">$N</option>";
}
?>
</select>
<input type="submit" name="Submit" value="Go">
</form> This is for the date selection, so therefore there would be two of these, the start date and the end date, that the client wants to view the data inside the database.

Please assist with the code, as i am not that good of a progammer.

Thanks & Regards

View Complete Thread with Replies

Related Items

Query failed: connection to localhost:3354 failed (errno=111, msg=Connection refused).