Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3664090
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:36:21+00:00 2026-05-19T01:36:21+00:00

Happy New Year Everyone! I have this existing php code I did when I

  • 0

Happy New Year Everyone!

I have this existing php code I did when I first started and I was wondering if there a way to make it OOP or if I should find another way of recreating it. All opinions welcome.

<?php
require("local_php.inc");
DatabaseConnect();

//Variables to post to results.php

$keyword=$_POST['keyword'];
$location=$_POST['location'];
$type=$_POST['type'];

//Query

$q1 = "SELECT ssearch.id, ssearch.Company, ssearch.Address, ssearch_state.state_location, ssearch.City, ssearch.Zip, ssearch.Phone, ssearch.Description, ssearch.Email, 
ssearch_event.Event_name FROM 

(ssearch LEFT OUTER JOIN ssearch_state ON ssearch.State = ssearch_state.id) 

LEFT OUTER JOIN  ssearch_event ON ssearch.Event_id = ssearch_event.id 

WHERE ssearch.Company LIKE '%$keyword%'";

if($location != "all")
{
 $q1 .= "AND ssearch_state.state_location ='$location' "; 
}
if($type != "all")
{
 $q1 .= "AND ssearch_event.Event_name ='$type' "; 
}
$q1 .= "ORDER BY ssearch.Company DESC LIMIT 0, 3;";
$result = mysql_query($q1);
$q1_total_rows = mysql_num_rows($result);

?>
<div id="content"> 
 <?php if($q1_total_rows >= 1) { ?>
 <?php while ($record = mysql_fetch_assoc($result)) { ?>
 <div id="table">
  <table width="379" height="64" border="0" align="left" bordercolor="#FFFF00" bgcolor="#FEFFD5">
   <tr>
    <td width="187"><p align="center" class="contentfontsmallsearch"><a href="display.php?ID=<?php echo $record["id"];?>"><?php echo $record["Company"];?></a></p></td>
    <td width="182"><p align="center" class="contentfontsmallsearch"><?php echo $record["Event_name"];?></p></td>
   </tr>
   <tr>
    <td><p align="center" class="contentfontsmallsearch"><?php echo $record["state_location"];?></p></td>
    <td><p align="center" class="contentfontsmallsearch"><?php echo $record["Description"];?></p></td>
   <tr>
  </table>
 </div>
 <?php } ?>
 <? } else { ?>
 <div id="table2">
 <h3 align="center" class="noresults">No Results</h3><br />
 <p align="center" class="contentfontsmallsearch">Please Try your Search Again</p><br />
 <form action="results.php" method="post" name="myform" id="myform">
  <table width="379" height="190" border="0" align="left" bordercolor="#FFFF00" bgcolor="#FEFFD5">
   <tr>
    <td width="143"><p align="center" class="contentfontsmallsearch">Keyword</p></td>
    <td width="226">
     <label>
       <input name="keyword" type="text" id="keyword" size="30" />
     </label>
    </td>
   </tr>
   <tr>
    <td><p align="center" class="contentfontsmallsearch">Location</p></td>
    <td>
     <select name="location">
       <option value="all" selected="selected">All Locations</option>
       <option value="Pennsylvania">Pennsylvania</option>
       <option value="New Jersey">New Jersey</option>
       <option value="Delaware">Delaware</option>
     </select>
    </td>
   <tr>
    <td width="143"><p align="center" class="contentfontsmallsearch">Event Type </p></td>
    <td>
     <select name="type">
       <option value="all" selected="selected">All Events</option>
       <option value="Rally Event">Rally Event</option>
       <option value="Awareness Event">Awareness Event</option>
       <option value="Donation Event">Donation Event</option>
     </select>
    </td>
   </tr>
   <tr>
    <td></td>
    <td><input type="submit" name="Submit2" value="Search" /></td>
   </tr>
  </table>
 </form>
 </div>
 <? } ?>
</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T01:36:22+00:00Added an answer on May 19, 2026 at 1:36 am

    I would prefer if you first made it secure. Add mysql_real_escape_string when reading the $_POST input variables. As it stands now, your code relies on magic_quotes to work at all.

    As second step, you could make this code procedural. Devise a location_query() function or something. I see no immediate structure that would benefit to jump to “making it OOP”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

first of all an Happy New Year to all :) I have found that
First of all-many season-greetings and a happy new year to all of you! Have
Happy New Year. I have a bunch of SOAP Web Services. They all have
Happy New Year 2010 everyone :) Just getting back into the Flash groove, and
Hi there (& Happy New Year!) Are there some examples on how I can
Firstly, Happy New Year everyone. I'm new to Rails, so please tolerate any incorrect
I've never been completely happy with the way exception handling works, there's a lot
Hi guys and happy new year(2010). I'm a kind of novice in WPF's ListView.
hope you all had a happy new year. So, my question is, what's the
I have the following code: private SetMultimap<String, Dynamic> dynamicFields = TreeMultimap.create(Ordering.natural(), new Comparator<Dynamic>() {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.