I need to make multiple queries and the second and third rely on data retrieved from the first one. The 1st one finds a user in a table. If the user is there then we go on. However if they are not there all my other queries are failing because information is missing. I need to gracefully stop the sequential queries if the are not in the db. I am working internally and cant give a link but my code is below.
Thanks in advance.
Thanks in advance.
Code:
//get the zip code from the form
$zipcode = ($_POST['zip']);
echo "<br>Here are the results for zip code: <div class=seek>$zipcode</div><br> ";
echo "<br><font color=#0072bc size= 3><b><u>Publisher Information</u></b></font><br><br>";
//select the db to use
$dbname = 'adnet';
mysql_select_db($dbname);
$query_publisher = "SELECT p.`pdata_id_publisher`, p.`pdata_zipcodes` FROM publisher_data p where `pdata_zipcodes` LIKE '%$zipcode%';";
//echo"$query_publisher <br>";
$result=mysql_query($query_publisher) or die ( "Couldn't execute query" );
$num=mysql_numrows($result);
if($num == 0 ){
echo"</p><p>There are no Publishers using that zip code.</p>" ;
else
}
//THIS IS WHERE I AM HAVING PROBLEMS
$i=0;
while ($i < $num) {
$Publisher_id=mysql_result($result,$i,"pdata_id_publisher");
$Owned_Zip=mysql_result($result,$i,"pdata_zipcodes");
//echo "<b>Publisher ID:</b>$Publisher_id<br><b>Zip Codes:</b>$Owned_Zip<br><br>";
$i++;
}
// Get the publishers details
$dbname = 'adnet';
mysql_select_db($dbname);
$query_publisher_details = "SELECT d.`jobno`, d.`contact`, d.`phone` FROM db_publishers d
WHERE d.`id_publisher` = '$Publisher_id'";
//echo"$query_publisher_details <br>";
$result=mysql_query($query_publisher_details) or die ( "Couldn't execute query" );
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
$name=mysql_result($result,$i,"contact");
$phone=mysql_result($result,$i,"phone");
$jobno=mysql_result($result,$i,"jobno");
echo " <b>Publisher:</b>$name<br> <b>Phone:</b>$phone<br> <b>Job No.</b>$jobno<br>";
$i++;
}
// Get the Publication details
$dbname = 'adnet2009';
mysql_select_db($dbname);
$query_publication = "SELECT d.community,d.code FROM db_publication_report d WHERE d.`zip` ='$zipcode' AND d.`id_publisher` = '$Publisher_id' and d.deleted is not null";
//echo"$query_publication <br>";
$result=mysql_query($query_publication) or die ( "Couldn't execute query" );
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
$community=mysql_result($result,$i,"community");
$code=mysql_result($result,$i,"code");
echo " <b>Community:</b>$community<br> <b>Published Editions:</b>$code<br><br>";
$i++;
}
Comment