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 8163953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:11:20+00:00 2026-06-06T19:11:20+00:00

I’m learning…I’ve read through the tutorials on http://www.w3schools.com , I’ve looked through the manual

  • 0

I’m learning…I’ve read through the tutorials on http://www.w3schools.com, I’ve looked through the manual on http://www.php.net and have a pretty good understanding of how everything works. But what I’m confused about how to structure my pages. What things should be put together on the same page and what should have it’s own page and just be included/required?

One of the things I still need to read up on is parameterizing, so don’t beat me up on that…yet.

Here is what I have:

a.php This is the page the user sees when they type in http://www.mydomain.com/a.php

<html>
<body>

<?php require("b.php"); ?>
// this requires that the page gets b.php and puts it here

<p>Name: <?php echo $row['firstname']; ?></p>
<p>Last Name: <?php echo $row['lastname']; ?></p>

</body>
</html>

b.php This page is included/required in a.php

<?php

require("../dbunamepword.php");
// this connects to my database

$query = ("SELECT * FROM contacts WHERE contacttype IN ('Buyer','Seller','Buyer / Seller','Investor') AND leadstatus = 'New' ORDER BY date DESC"); 
$result = $mysqli->query($query) or die ("Error: ".mysqli_error($mysqli));
while ($row = $result->fetch_array()) {
// this fetches the data I want from the table in my db while all cases match above

$firstname = $row ['firstname'];     
$lastname = $row['lastname'];
// these are the rows in the table I want to fetch 

echo "First Name: " . $firstname . " " .$lastname ."<br />";
// this is how I want the data presented

}
?>

Here are my questions Thank you in advance:

1) How would using functions benefit me in building these pages or would they not benefit me?

2) Couldn’t I leave out the echo on b.php and just call the rows in a.php like below and put in a foreach statement? I actually tested this and I kept getting an unexpected $end error so I’m not sure if this is not a good way or if I did something wrong?

<html>
<body>

<?php require("b.php"); ?>
// this requires that the page gets b.php and puts it here

<p>Name: <?php echo $firstname; ?></p>
<p>Last Name: <?php echo $lastname; ?></p>

</body>
</html>

3) Let’s say I add in some if/else statements like below, should I put these in b.php or put them in their own file c.php and then put an include in b.php?

if(isset($_GET['leadstatus']) && $_GET['leadstatus'] == "All")
{
$query = "SELECT * FROM contacts WHERE contacttype IN ('Buyer','Seller','Buyer / Seller','Investor') ORDER BY contacts.date DESC";  
}
elseif (in_array($_GET['leadstatus'], array('New', 'Hot', 'Warm', 'Cold', 'Rejected', 'Closed')))
{  
$status = $_GET['leadstatus'];   
$query = "SELECT * FROM contacts WHERE leadstatus = '".$status."' AND contacttype IN ('Buyer','Seller','Buyer / Seller','Investor') ORDER BY contacts.date DESC";
}

4) In my $query I have SELECT * FROM contacts WHERE contacttype IN ('Buyer','Seller','Buyer / Seller','Investor') rather than typing that out in every if/else statement or lets say I needed to add another field like, ‘Renter’, could I do something like:

$type = ('Buyer','Seller','Buyer / Seller','Investor')

$query = ("SELECT * FROM contacts WHERE contacttype = $type AND leadstatus = 'New' ORDER BY date DESC"); 


if (($_GET['date'] == 'today'))
{     
$$query = "SELECT * FROM contacts WHERE contacttype = $type AND date = DATE(NOW()) ORDER BY date DESC";
}

if (($_GET['date'] == 'thisweek'))
{     
$thisweek = date('Y-m-d', strtotime('last sunday'));
$query = "SELECT * FROM contacts WHERE contacttype = $type AND date BETWEEN '$thisweek' AND '$thisweek' + INTERVAL 7 DAY ORDER BY date DESC";
}
  • 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-06-06T19:11:22+00:00Added an answer on June 6, 2026 at 7:11 pm

    I would recommend you start using a micro-framework to help you organize your code. One that I prefer is Silex because it promotes/encourages good programming habits/practices and as your projects grow you can seamlessly evolve into the more full-stack world of Symfony.

    You don’t need a framework, but I believe they can help you learn best-practices for organizing any codebase even if you decide not to use one for some projects.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
this is what i have right now Drawing an RSS feed into the php,
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I am trying to loop through a bunch of documents I have to put
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
I have a jquery bug and I've been looking for hours now, I can't

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.