Jump to content

Location Mapping


quantumdecipher

Recommended Posts

Hi guys, I am making a simple program which fetches an array of variables on my table. Basically, I want to map the location of a unit which is plugged into a certain location.

 

The layout consists of 40 locations. I'll be representing them using tables. Lets say I have a table with 1 row and 40 columns which portrays the 40 locations. Lets say, collectively all 40 locations are on Area 238. So each location is labeled 238-1 ... 238-40). In my database I have a field called portNumber which has a value of say 238-11. Now I want the code to check all those data entries with the portNumber LIKE 238, and highlight all rows which return a value. Those without value will remain white. Also the highlighted values should check is the field isHistory is set to 0 otherwise, it won't return the value.

 

Here's the code I did so far:

<!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>Location Mapper</title>
</head>

<body>
<table width="800" border="1" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <th colspan="40" scope="col">SCMST 238</th>
  </tr>
  <tr>
	<?php
    	$conn = mysql_connect("localhost", "root", "123456") or die(mysql_error()); 
	mysql_select_db("orderstatus") or die(mysql_error());
	$sql = mysql_query("SELECT * FROM superdome WHERE portNumber LIKE '%238%' AND isHistory='0' ORDER BY portNumber ASC")
		or die(mysql_error());

	if(mysql_num_rows($sql) != 0) {
		echo "
			    <td width=\"20\" height=\"30\" scope=\"row\"> </th>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
				<td width=\"20\"> </td>
		";
	}
?>
  </tr>
</table>
</body>
</html>

 

So if the query for mysql_num_rows return 0, nothing should be highlighted as shown in the picture:

68596861.jpg

 

but if the query for mysql_num_rows return a value, all values in the array should be highlighted as shown:

33232598.jpg

 

Location 5 and 40 are highlighted.

Really need help on this one... Thanks!

Link to comment
https://forums.phpfreaks.com/topic/247105-location-mapping/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.