Hi all
I would like to use variable to get only 'ref_id' from form.php to select another record in other table.
Please help!
form.php
<form method=post action="view.php">
<select name="resource">
<option>Select here!</option>
<?php
include 'coninfo.php';
$sql = "SELECT ref_id, title FROM tblreferences";
$rs = mysql_db_query($DB_Name, $sql);
while ($rs_array = mysql_fetch_array($rs))
{
?>
<option value="<?=$rs_array['ref_id']?>"><?$rs_array ['ref_id']?>, <?= substr($rs_array['title'], 0, 40); ?>...</option>
<?
}
?>
</select>
</form>
view.php
<?
$varRef = $_POST('resource');
$SQL="SELECT COUNT() AS Total FROM tblreferences WHERE ref_id = '%".$varRef."%'";
$SQL_Result=mysql_db_query($DB_Name, $SQL) or die (mysql_error());
$SQL_Result_Array=mysql_fetch_array($SQL_Result);
$Total=$SQL_Result_Array['Total'];
// Create a new SELECT Query with the ORDER BY clause and without the COUNT()
$SQL="SELECT * FROM tblreferences WHERE ref_id = '%"$varRef"%'";
?>