Jump to content

Select From Help


ben.hornshaw

Recommended Posts

Hi i am new to PHP and this forum and wondered if one of you guys could give me a hand.

 

I have a php page that references 4 tables, this is fine but i need to query one table and then query the other three relative to the first query. this i made work on one table as follows.

mysql_select_db($database_entinfo, $entinfo);
$query_Manufacturer = sprintf("SELECT * FROM Manufacturer WHERE Manufacturer_ID = %s", GetSQLValueString($colname_Manufacturer, "int"));
$Manufacturer = mysql_query($query_Manufacturer, $entinfo) or die(mysql_error());
$row_Manufacturer = mysql_fetch_assoc($Manufacturer);
$totalRows_Manufacturer = mysql_num_rows($Manufacturer);

 

So this finds the record in the Manufacturers table that has the same ID as the Manufacturer field from the Equipment Table the page already has a record set for

 

Therefore i just added more of these but i get an error saying unexpected ","

 

my code is as follows

$colname_Equipment = "-1";
if (isset($_GET['EquipID'])) {
  $colname_Equipment = $_GET['EquipID'];
}
mysql_select_db($database_entinfo, $entinfo);
$query_Equipment = sprintf("SELECT * FROM Equipment WHERE Equipment_ID = %s", GetSQLValueString($colname_Equipment, "int"));
$query_limit_Equipment = sprintf("%s LIMIT %d, %d", $query_Equipment, $startRow_Equipment, $maxRows_Equipment);
$Equipment = mysql_query($query_limit_Equipment, $entinfo) or die(mysql_error());
$row_Equipment = mysql_fetch_assoc($Equipment);

if (isset($_GET['totalRows_Equipment'])) {
  $totalRows_Equipment = $_GET['totalRows_Equipment'];
} else {
  $all_Equipment = mysql_query($query_Equipment);
  $totalRows_Equipment = mysql_num_rows($all_Equipment);
}
$totalPages_Equipment = ceil($totalRows_Equipment/$maxRows_Equipment)-1;

$colname_Manufacturer = "-1";
if (isset($row_Equipment['Manufacturer'])) {
  $colname_Manufacturer = $row_Equipment['Manufacturer'];
}
mysql_select_db($database_entinfo, $entinfo);
$query_Manufacturer = sprintf("SELECT * FROM Manufacturer WHERE Manufacturer_ID = %s", GetSQLValueString($colname_Manufacturer, "int"));
$Manufacturer = mysql_query($query_Manufacturer, $entinfo) or die(mysql_error());
$row_Manufacturer = mysql_fetch_assoc($Manufacturer);
$totalRows_Manufacturer = mysql_num_rows($Manufacturer);

mysql_select_db($database_entinfo, $entinfo);
$query_Connectors = "SELECT * FROM Connectors WHERE Conn_ID = %s", GetSQLValueString($colname_Standard Connector, "int"));
$Connectors = mysql_query($query_Connectors, $entinfo) or die(mysql_error());
$row_Connectors = mysql_fetch_assoc($Connectors);
$totalRows_Connectors = mysql_num_rows($Connectors);

mysql_select_db($database_entinfo, $entinfo);
$query_DataConnectors = "SELECT * FROM Connectors WHERE Conn_ID = %s", GetSQLValueString($colname_Data Connector, "int"));
$DataConnectors = mysql_query($query_DataConnectors, $entinfo) or die(mysql_error());
$row_DataConnectors = mysql_fetch_assoc($DataConnectors);
$totalRows_DataConnectors = mysql_num_rows($DataConnectors);

 

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/194172-select-from-help/
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.