0

Dear All;
I have table in vehicle.php file that contains vehicle information(plate number, vehicle model, reg. and exp. dates). I pprovided each record with href(more) if he want to know more about this specific vehicle in vehicle-info.php file. in vehicle-info.php I get the plateN and I pass it to the SQL command "Select * from $table where plateN = '$plateN';" However this was not working.
Can you guide me.
I attached my vehicle-info.php
Thanks alots...

Attachments
<html>
<head>
       <title>More Information</title>
</head>
<body>
 <?php

 $host      = "localhost";
 $user      = "";
 $password  = "";
 $db        = "DMV";
 $table     = "myvehicleinfo";

  mysql_connect($host,$user,$password) or die("Failed to connect");

  mysql_select_db($db) or die("Failed to select database");

  $plateN = $_GET["PlateN"];
  $sql = "SELECT * from $table where plateN='$plateN'";

  $result = mysql_query($sql);

  if ($row = mysql_fetch_array($result))
  {
     echo "<p align=\"left\"><font face=\"Times New Roman\" size=\"5\">Detail information about your
          	<font color=\"#FF0000\">chosen Vehicle</font></p>";

     echo
         "<table border=\"1\" width=\"72%\" id=\"table1\" style=\"border-width: 0px\">
	        <tr>
                <th width=\"161\" align=\"left\" style=\"border-style: none; border-width: medium\">
                <p dir=\"ltr\" align=\"left\">Plate Number:</th>
	            <td style=\"border-style: none; border-width: medium\">
                <p dir=\"ltr\" align=\"left\">$row[0]</td>
		    </tr>
		    <tr>
	            <th width=\"161\" align=\"left\" style=\"border-style: none; border-width: medium\">
			<p dir=\"ltr\" align=\"left\">Plate Color:</th>
			<td style=\"border-style: none; border-width: medium\">
			<p dir=\"ltr\" align=\"left\">$row[1]</td>
		</tr>
		<tr>
			<th width=\"161\" align=\"left\" style=\"border-style: none; border-width: medium\">
			<p dir=\"ltr\" align=\"left\">Plate Type:</th>
			<td style=\"border-style: none; border-width: medium\">
			<p dir=\"ltr\" align=\"left\">$row[2]</td>
		</tr>
		<tr>
			<th width=\"161\" align=\"left\" style=\"border-style: none; border-width: medium\">
			<p dir=\"ltr\" align=\"left\">Vehicle Type:</th>
			<td style=\"border-style: none; border-width: medium\">
			<p dir=\"ltr\" align=\"left\">$row[3]</td>
		</tr>
		<tr>
			<th width=\"161\" align=\"left\" style=\"border-style: none; border-width: medium\">
			<p dir=\"ltr\" align=\"left\">Vehicle Model:</th>
			<td style=\"border-style: none; border-width: medium\">
			<p dir=\"ltr\" align=\"left\">$row[4]</td>
		</tr>
		<tr>
			<th width=\"161\" align=\"left\" style=\"border-style: none; border-width: medium\">
			Vehicle Color:</th>
			<td style=\"border-style: none; border-width: medium\">$row[5]</td>
		</tr>
		<tr>
			<th width=\"161\" align=\"left\" style=\"border-style: none; border-width: medium\">
			Manufactured Country:</th>
			<td style=\"border-style: none; border-width: medium\">$row[6]</td>
		</tr>
		<tr>
			<th width=\"161\" align=\"left\" style=\"border-style: none; border-width: medium\">
			Insurance Company:</th>
			<td style=\"border-style: none; border-width: medium\">$row[7]</td>
		</tr>
		<tr>
			<th width=\"161\" align=\"left\" style=\"border-style: none; border-width: medium\">
			Insurance Type:</th>
			<td style=\"border-style: none; border-width: medium\">$row[8]</td>
		</tr>
		<tr>
			<th width=\"161\" align=\"left\" style=\"border-style: none; border-width: medium\">
			Contract Number:</th>
			<td style=\"border-style: none; border-width: medium\">$row[9]</td>
		</tr>";


  while($row = mysql_fetch_array($result));

     echo"</table></div>";
  }
     else

        echo "<p><i><b><font face=\"Chiller\" size=\"6\" color=\"#FF0000\">Sorry dear</font><font face=\"Chiller\" size=\"5\" color=\"#800000\">,
             there is may be an error in our system, please contact us.</font></b></i></p>";
?>

</body>
</html>
4
Contributors
15
Replies
16
Views
9 Years
Discussion Span
Last Post by GliderPilot
0

What is the SQL error? That error message should tell you what is wrong and point you in the right direction towards fixing it.

0

I put the condition as following
while($row = mysql_fetch_array($result));
echo"</table></div>";
}
else
echo "<p><i><b><font face=\"Chiller\" size=\"6\" color=\"#FF0000\">Sorry dear</font><font face=\"Chiller\" size=\"5\" color=\"#800000\">,
there is may be an error in our system, please contact us.</font></b></i></p>";

0

Sorry dear,
there is may be an error in our system, please contact us.

0

I took a look at the code and the only things I can see is to check the spelling (case sensitive) of the Index in your $_GET array.

Personally I would change the if statement. check if your result variable contains any data, and move your fetch array down into the if block. Than add a mysql_error(); to your error at the end. This way if your query fails it will tell you what happened so you can fix it. As well I would enclose the code of your else statement in { and } to ensure proper processing. Otherwise evan when it works it will possibly show your error.

I.E.

$result = mysql_query($sql);
 
if ($result)
{
  $row = mysql_fetch_array($result);
 
  ... (Rest of code)
 
}
else
{
 
  ...error code here...
 
  mysql_error();
 
}

After you do that if you still have errors, they should be more detailed and we will be able to help you out furthur.

0

The problem now, that I can't view specific info. for specific record.
I wrote
$plateN = $_GET["PlateN"];
$sql = "SELECT * from $table where plateN='$plateN'";

But it does not retriev any data from my DB!

0

Ok so the problem is passing the info between the pages... What does the link look like on vehicle.php that sends you to vehicle-info.php ??

0

That is your problem you do not define the veriable name in your link. Modify it to this and it should work:

<th><a href='My-Vehicle-info.php?PlateN=" . $myrow[0] . "'>More</a></th>

0

After you click the link, goto the top of the page in the address bar and copy and paste the link you have starting at My-Vehicle-info.php right to the end.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.