Dear all
I am a beginner in web development. Please help to resolve the below problem. Right now I am creating a Workers Directory with sql database.
This is including worker name, Location, Work and mobile numbers.
When customer select the specific job we need to filter particular job from available location and while click on location from second page show only the specific workers from that same location
This is the my First page Index.php
<?php require('config1.php'); ?>
<!doctype html>
<html class="no-js" lang="en-US">
<head>
<title> Info - </title>
</head>
<body>
<div data-role="page" id="home" data-theme="c">
<div data-role="content">
<div id="branding">
<h1> Info</h1>
</div>
<div class="choice_list">
<h1> What are you looking? </h1>
<ul data-role="listview" data-inset="true" data-filter="true">
<li><a href="choose_town.php" data-transition="slidedown"> <img src="images/ac_technician.jpg"/> <h3>AC Technician</h3></a></li>
<li><a href="choose_town.php" data-transition="slidedown"> <img src="images/beautician.jpg"/> <h3>Beautician.jpg</h3></a></li>
<li><a href="choose_town.php" data-transition="slidedown"> <img src="images/cricket_umpire.jpg"/> <h3>Cricket Umpire</h3></a></li>
<li><a href="choose_town.php" data-transition="slidedown"> <img src="images/carpenter.jpg"/> <h3>Carpenters </h3></a></li>
<li>etc...<li>
</ul>
</div>
</div>
</div><!-- /page -->
</body>
</html>
My Second Page choose_town.php
<?php
$con=mysqli_connect("localhost","user","pass","mydb");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT DISTINCT location FROM nilambur_info ");
while($row = mysqli_fetch_array($result))
{
echo "<ul class='ui-listview ui-listview-inset ui-corner-all ui-shadow'; >";
echo "<li data-theme='c'; class='ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-li-has-count ui-btn-up-c';><div class='ui-btn-inner ui-li';><div class='ui-btn-text';><a href='choose_worker.php'; data-transition='slidedown'; class='ui-link-inherit';> " . $row['location'] . "<span class='ui-li-count ui-btn-up-c ui-btn-corner-all';>2 </span></a> </div><span class='ui-icon ui-icon-arrow-r ui-icon-shadow'></span></div></li>";
echo "</ul>";
}
mysqli_close($con);
?>
My third page choose_worker.php
<?php require('config1.php'); ?>
<?php
$query1=mysql_connect("localhost","user","pass","mydb");
mysql_select_db("nilambu1_mydb",$query1);
$start=0;
$limit=10;
if(isset($_GET['id']))
{
$id=$_GET['id'];
$start=($id-1)*$limit;
}
$query=mysql_query("select id, first_name, last_name, mobile1, mobile2 from nilambur_info ORDER BY id DESC LIMIT $start, $limit");
while($row=mysql_fetch_array($query))
{
echo '<li><a href="contact.php?id='.$row['id'].'" data-transition="slidedown"><img src="images/calling.png"/><h2>'.$row['first_name'].' '.$row['last_name'].'</h2><p>Mobile : '.$row['mobile1'].' , '.$row['mobile2'].'</p></a></li>';
}
$rows=mysql_num_rows(mysql_query("SELECT id, first_name, last_name, mobile1 FROM nilambur_info"));
$total=ceil($rows/$limit);
if($id>1)
{
echo "<a href='?id=".($id-1)."' class='button'>PREVIOUS</a>";
}
if($id!=$total)
{
echo "<a href='?id=".($id+1)."' class='button'>NEXT</a>";
}
echo "<ul class='page'>";
for($i=1;$i<=$total;$i++)
{
if($i==$id) { echo "<li class='current'>".$i."</li>"; }
else { echo "<li><a href='?id=".$i."'>".$i."</a></li>"; }
}
echo "</ul>";
?>
forth page contact.php
<?php require('config1.php');
$stmt = $db->prepare('SELECT id, first_name, last_name, mobile1, mobile2, land_line, address, location, job FROM nilambur_info WHERE id = :id');
$stmt->execute(array(':id' => $_GET['id']));
$row = $stmt->fetch();
$url = $_SERVER['REQUEST_URI'];
$query = $_SERVER['QUERY_STRING'];
//if post does not exists redirect user.
if($row['id'] == ''){
header('Location: ./');
exit;
}
?>
<?php
echo '<div data-role="content">';
echo '<div class="ui-grid-a" id="restau_infos">';
echo ' <div class="ui-block-a">';
echo ' <h1>'.$row['first_name'].' '.$row['last_name'].'</h1>';
echo ' <p><strong>'.$row['job'].'</strong></p>';
echo ' <p> Contact Details </p>';
echo ' <ul> ';
echo ' <li> Mobile:'.$row['mobile1'].'</li>';
echo ' <li> Whatsapp :'.$row['mobile2'].'</li>';
echo ' <li> Land Phone or Email : '.$row['land_line'].'</li>';
echo ' </ul> ';
echo ' </div> ';
echo ' <div class="ui-block-b">';
echo ' </div>';
echo '</div>';
echo '<!-- /grid-a -->';
echo '<hr/>';
echo '<div class="ui-grid-a" id="contact_infos">';
echo ' <div class="ui-block-a">';
echo ' <h2> Contact us</h2>';
echo ' <p>'.$row['address'].'</p>';
echo ' <p>'.$row['location'].'</p>';
echo ' </div> ';
echo ' <div class="ui-block-b">';
echo ' </div>';
echo '</div><!-- /grid-a -->';
echo '<div id="contact_buttons">';
echo ' <a href="tel:'.$row['mobile1'].'" data-role="button" data-icon="tel"> Call us</a> ';
echo ' <a href="choose_worker.php" data-role="button" data-transition="slideup" > Back</a>';
echo ' <a href="index.php" data-role="button" data-transition="slideup" > Back to Home </a>';
echo '</div> ';
echo '<hr/>';
?>