Jump to content

Page not displaying retrieved information *solved*


hostfreak

Recommended Posts

I've got a system setup to manage trucks etc. Well when a truck is added, it is assigned to an agent. In the truck table, where the trucks are added, there is a field called id2. The id2 receives the value of the id of the user that it is assigned to. That way it is unique to that user. Well for some reason, when I try to call it to display trucks under that user, it doesn't display anything. No errors etc. Here is my code:

[code]
<?php
include("include/session.php");
if($session->logged_in){
include ("top.txt");
include("include/constants.inc");
?>

<table id="settingstable">
<tr>
<td id="settingstd3">
<a href=amta.php><b><u>A</u></b></a>
<a href=amtb.php><b><u>B</u></b></a>
<a href=amtc.php><b><u>C</u></b></a>
<a href=amtd.php><b><u>D</u></b></a>
<a href=amte.php><b><u>E</u></b></a>
<a href=amtf.php><b><u>F</u></b></a>
<a href=amtg.php><b><u>G</u></b></a>
<a href=amth.php><b><u>H</u></b></a>
<a href=amti.php><b><u>I</u></b></a>
<a href=amtj.php><b><u>J</u></b></a>
<a href=amtk.php><b><u>K</u></b></a>
<a href=amtl.php><b><u>L</u></b></a>
<a href=amtm.php><b><u>M</u></b></a>
<a href=amtn.php><b><u>N</u></b></a>
<a href=amto.php><b><u>O</u></b></a>
<a href=amtp.php><b><u>P</u></b></a>
<a href=amtq.php><b><u>Q</u></b></a>
<a href=amtr.php><b><u>R</u></b></a>
<a href=amts.php><b><u>S</u></b></a>
<a href=amtt.php><b><u>T</u></b></a>
<a href=amtu.php><b><u>U</u></b></a>
<a href=amtv.php><b><u>V</u></b></a>
<a href=amtw.php><b><u>W</u></b></a>
<a href=amtx.php><b><u>X</u></b></a>
<a href=amty.php><b><u>Y</u></b></a>
<a href=amtz.php><b><u>Z</u></b></a>
</td>
</tr>
</table>
<?php
$connection = mysql_connect("$server","$user","$password"); 
mysql_select_db("$database", $connection);

$sql = "SELECT * FROM users WHERE username = '$username'";
$result = mysql_query($sql, $connection) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$id_num = $row['id_num'];
}

$sql = "SELECT * FROM trucks";
$result = mysql_query($sql, $connection) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$id2 = $row['id2'];
}

$letter = 'A';
$sql = "SELECT * FROM trucks WHERE id2 = '$id_num' AND company LIKE '$letter%' ORDER BY company ASC";
$result = mysql_query($sql, $connection) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$company = $row['company'];
$mc = $row['mc'];
?>

<table id="settingstable">
<tr>
<td></td>
<tr>

<tr>
<td id="settingstd1">Company Name:</td>
<td id="settingstd2"><?php echo "$company"; ?></td>
</tr>

<tr>
<td id="settingstd1">MC #:</td>
<td id="settingstd2"><?php echo "$mc"; ?></td>
</tr>

<tr>
<td id="settingstd1">Delete:</td>
<td id="settingstd2"><a href='deltrequest.php'>Delete Truck</a></td>
</tr>

<tr>
<td id="settingstd1">Edit Truck:</td>
<td id="settingstd2"><a href='edittrequest.php'>Edit Truck Information</a></td>
</tr>
</table>

<?php
}
include ("bottom.txt");
}
else { //If the user is not logged in, warn them
$ip = $_SERVER['REMOTE_ADDR'];
echo "You are not authorized to view this page! An email has been dispatched to the administrators to inform them of your whereabouts!<br>Your IP address: <b>$ip</b> , has been recorded and will be reported to the law if this happens again!";
}
?>
[/code]
When in doubt, echo the query to see what it [b]really[/b] is:

[code]$sql = "SELECT * FROM trucks WHERE id2 = '$id_num' AND company LIKE '$letter%' ORDER BY company ASC";
echo "Debug: ". $sql. "<br/>"; // so what is the query exactly?
$result = mysql_query($sql, $connection) or die(mysql_error());[/code]

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.