Jump to content

Search the Community

Showing results for tags 'if else statement'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. I am working on a project that involves providing details for county government, and if applicable, cities independent of county oversight. Virginia is a state with a lot of independent cities, so I wanted to echo them in a separate list underneath the county governments. This code works fine when displaying Virginia information. However, I would like to hide the Independent Cities heading in every other state. For some reason, this code still echoes the Independent Cities heading in states without independant cities in the database. Any thoughts or wisdom? (sorry for pasting the whole bulky code) $query = "SELECT * FROM state WHERE st_id=$statecode"; $result = mysql_query($query) or die("Query $query failed : " . mysql_error()); $row = mysql_fetch_assoc($result); $state_name=$row["st_name"]; $state_note=$row["state_notes"]; echo "<h2>Counties of " . $state_name; "</h2>\n"; $query = "SELECT * FROM counties WHERE st_id=$statecode AND visible=1 ORDER BY county_name ASC"; $result = mysql_query($query) or die("Query $query failed : " . mysql_error()); echo "<table width=100%><tr><td valign=top width=33%>\n"; $count = 1; $col = 0; $rowcount = (int)(mysql_num_rows($result) / 3) + 1; $remainder = mysql_num_rows($result) - ($rowcount - 1) * 3; /* ********************************************************* */ while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<a href=\"services.php?county=".$row["county_id"]."\">".$row["county_name"] . "</style></a><br />\n"; $count = $count + 1; if ((($remainder > 0) && ($count == ($rowcount + 1))) || (($remainder <= 0) && ($count == $rowcount))) { $col = $col + 1; if ($col!=3) { echo "</td><td valign=top width=33%>\n"; $count = 1; if ($remainder > 0) $remainder = $remainder - 1; } } } /* ********************************************************* */ echo "</td></tr></table><br>\n"; mysql_free_result($result); /* ********************************************************* */ $query2 = "SELECT * FROM cities WHERE st_id=$statecode AND visible=1 ORDER BY city_name ASC"; $result2= mysql_query($query2) or die("Query $query failed : " . mysql_error()); $city_id = $row['city_id']; $city_name = $row['city_name']; if ($city_id!="") { echo "<h3>Independent cities of " . $state_name; "</h3>\n"; echo "<table width=100%><tr><td valign=top width=33%>\n"; $count2 = 1; $col2 = 0; $rowcount2 = (int)(mysql_num_rows($result2) / 3) + 1; $remainder2 = mysql_num_rows($result2) - ($rowcount2 - 1) * 3; /* ********************************************************* */ while ($row = mysql_fetch_array($result2, MYSQL_ASSOC)) { echo "<a href=\"services.php?county=".$row["city_id"]."\">".$row["city_name"] . "</style></a><br />\n"; $count2 = $count2 + 1; if ((($remainder2 > 0) && ($count2 == ($rowcount2 + 1))) || (($remainder2 <= 0) && ($count2 == $rowcount2))) { $col2 = $col2 + 1; if ($col2!=3) { echo "</td><td valign=top width=33%>\n"; $count2 = 1; if ($remainder2 > 0) $remainder2 = $remainder2 - 1; } } } /* ********************************************************* */ echo "</td></tr></table><br>\n"; mysql_free_result($result2); /* ********************************************************* */ } ?>
×
×
  • 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.