By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,949 Members | 1,824 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,949 IT Pros & Developers. It's quick & easy.

Getting Info. for specific record?

P: 6
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.
Thanks alots...
May 2 '07 #1
Share this Question
Share on Google+
3 Replies


cyberking
P: 84
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.
Thanks alots...

Hi!
Your post seems very abstract to me,. How can you query using SQL commads from a table that you have in vehicle.php file? Or do you mean to say that you have code in vehicle.php that query's your table in database? I am unable to understand.. If, you have a table in your database, then what you can do is :

Say you have a link for plate number in some page, then provide a link to this,

<a href='vehicle.php?plateN=$plateN'>Plate_number</a>

Now in vehicle.php

$plateN = $_GET['plateN'] ;
and for your query:

$result = mysql_query("SELECT * FROM table_name WHERE plateN = '$plateN' ");

And now you can use the fetched values. This ll work! But I dont know if this is what you are actually wanting to do! The reason is, I am unable to understan your post.

Regards
CyberKing
http://www.bytesandbytes.com
May 2 '07 #2

P: 6
Hi;;
In vehicle.php I query some information about vehicle. Then there is a link bypass each record {more}. when a user click on it, the more detailed information about the vehicle will appeared in vehicle-info.php file. The problem was How can I get the specific infor for that record.
Here are my files:

vehicle.php
========
<html>
<head>
<title>Displaying Your Vehicles</title>
</head>
<body>
<?php

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

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

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


$sql = "SELECT * from $table ORDER BY platen ASC";

$result = mysql_query($sql);

if ($row = mysql_fetch_array($result))
{
echo "<p align=\"center\"><font size=\"5\" color=\"#FF0000\">&lt;&lt;Your Vehicles&gt;&gt;</font></p>";

echo
"<table border=\"1\" width=\"100%\" id=\"table1\">
<tr>
<th>
<p dir=\"ltr\">Plate Number</th>
<th>
<p dir=\"ltr\">Vehicle Model</th>
<th>
<p dir=\"ltr\">Registration Date</th>
<th>
<p dir=\"ltr\">Expire Date</th>
<th>
<p dir=\"ltr\">More Info.</th>
</tr>";


do {

echo "<tr>
</tr>";

echo " <tr>
<th>$row[0]</th>
<th>$row[1]</th>
<th>$row[2]</th>
<th>$row[3]</th>
<th><a href=My-Vehicle-info.php?=".$myrow[0].">More</th>
</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>


vehicle-info.php
===========
<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>
May 2 '07 #3

ak1dnar
Expert 100+
P: 1,584
Make it as a Hyperlink </a> is missing.
and you are not passing the PlateN to next page over the URL.
try this.
[PHP]<a href=My-Vehicle-info.php?PlateN=".$myrow[0].">More</a>[/PHP]
May 3 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.