Jump to content

[SOLVED] selecting the next record from my db


ballhogjoni

Recommended Posts

This is what I am trying to do.

 

I am trying to select the first row from the contactinfo table that has multiple colums (5-6).

At the same time I am trying to selcet the first row from the question2checkbox table that has multiple colums (5-6).

and so on for each query in the code examples above.

 

Of course I am putting them in an array so that I can use the info that is selected from these tables to print to my browser.

 

Now when I click the next button that I created with a form, the form just refreshes this script so that it will bring up the next row in each table as specified above. IE...

 

the second row from the contactinfo table that has multiple colums (5-6).

At the same time selcet the second row from the question2checkbox table that has multiple colums (5-6).

and so on for each query in the code examples above.

 

I might be creating a bigger headache than it should be.

Link to comment
Share on other sites

Well in order to get this to work you will have to redesign your tables. All you should need is 3 tables.

 

Name and structure

Contactinfo:
id
name
title

Questions:
id
question

Answers:
contactid
questionid
answer

 

and they would link together

contactinfo.id --> answer.contactid, answer.questionid --> questions.id.

 

You can put all your questions into the question table.

 

If you give me the questions you want I can put something together for you quick.

 

Ray

 

Link to comment
Share on other sites

1. Are you a surveyor and/or engineer?*

 

yes or no

 

1a. If you answered ‘Yes’ to the question above, which of the following problems do you face on a daily basis? Check all that apply.

Project Tracking:

Personnel Inefficiency:

Financial Reporting:

Invoicing & Billing:

Scheduling:

Other:

 

2. Would you be interested in a Project Management Program that would result in making your company 15%-30% more efficient in a year’s time--guaranteed?

 

yes or no

 

3. If you answered ‘Yes, you are interested' – how interested are you?

 

Very Interested | Sort of Interested | Kind of Interested

 

4. Please rank these in order of importance (1,2,3,4,5) with #1 the most important, #5 the least important, etc.*

Tracking projects from field to office more efficiently:

Tracking one and/or multiple employees' times to make your company more efficient:

Calculate job profitability on every job in real time at a click of a button:

Give your clients a way to track jobs, order jobs, and check on invoices and statements without ever calling your office:

Having a Software solution be 100% customizable to your needs:

 

5. Which would you most likely buy in the next 3-6 months.*

A Total Station:

Project Management Software:

A TDS Recon:

Consulting for your company (teaches your company more efficient surveying & engineering techniques):

Accounting and Payroll Software:

Other:

 

6. Would you be interested in Independent Reviews of various project management software programs designed specifically for surveyors and engineers?*

 

yes or no

 

7. If you answered ‘Yes’ to question 6 -- How interested?

 

Very Interested | Sort of Interested | Kind of Interested

 

8. “The first rule of any technology used in a business is that automation applied to an efficient operation will magnify the efficiency." - Bill Gates; Research has shown that implementing a project management program into an efficient firm can save $15,000 to $45,000 a year in company expenses. Would you be interested in a program that can do this? *

 

yes or no

 

9. If you answered ‘Yes’ to question 8 -- What would be the best day to contact you and go over a 30 minute demonstration?*

 

Monday | Tuesday | Wedensday | Thursday | Friday

 

and then contact info

 

Name: first and last | Phone: areacode-prefix-linenumber | Email: | Position: | State:

Link to comment
Share on other sites

I finally figured it out. ;D thank you for everyone's help. here is the code if anyone wants to know how to do it themselves. I am also posting it on my site that you can find in my profile.

<?php
$username="xxxx";
$password="xxxx";
$database="xxxx";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

if(!isset($_GET['page'])){ 
    $page = 1; 
} else { 
    $page = $_GET['page']; 
} 

$max_results = 1; 

// Figure out the limit for the query based 
// on the current page number. 
$from = (($page * $max_results) - $max_results);  

$sql = mysql_query("SELECT * FROM contactinfo LIMIT $from, $max_results");  
$sql1 = mysql_query("SELECT * FROM question2checkbox LIMIT $from, $max_results");
$sql2 = mysql_query("SELECT * FROM questions123 LIMIT $from, $max_results");
$sql3 = mysql_query("SELECT * FROM question4 LIMIT $from, $max_results");
$sql4 = mysql_query("SELECT * FROM question5 LIMIT $from, $max_results");
$sql5 = mysql_query("SELECT * FROM question6789 LIMIT $from, $max_results");
?>
<html>
<head>
<title>Print Leads</title>
</head>
<body bgcolor="#999999">
<table width="900" align="center" border="0" bgcolor="#FFFFFF" cellpadding="5" cellspacing="5">
<tr>
	<td>
		<!-- Contact Info -->
		Name: <?php while($row = mysql_fetch_array($sql)){ echo "<font color=red>" .$row['fname']." ".$row[
		'lname']. "</font>"; 
		echo " | Phone: <font color=red>" .$row['areacode']."-".$row['prefix']."-".$row[
		'linenumber']."</font>";
		echo " | Email: <font color=red>" .$row['email']."</font> | Position: <font color=red>" .$row['position']."
		</font> | State: <font color=red>" .$row['state']."</font>";}?>
		<!-- Question 1 -->
		<p>1. Are you a surveyor and/or engineer?*
		<?php while($row2 = mysql_fetch_array($sql2)){ echo " <font color=red>".$row2['question1']."</font>";
		//<!-- Question 2 -->
		echo "<p>2. Would you be interested in a Project Management Program that would result in making your company 15%-30% more 
		efficient in a year’s time--guaranteed?";
		echo " <font color=red>".$row2['question2']."</font>";
		//<!-- Question 3 -->
		echo "<p>3. If you answered \"Yes, you are interested\" – how interested are you?";
		echo " <font color=red>".$row2['question3']."</font>"; }?>
		<!-- Question 1a -->
		<p>1a. If you answered ‘Yes’ to question one, which of the following problems do you face on a daily
		basis?
		<br />Project Tracking: <?php while($row1 = mysql_fetch_array($sql1)){ 
		echo "<font color=red>" .$row1['question2q1']."</font>";
		echo "<br />Personnel Inefficiency: <font color=red>" .$row1['question2q2']."</font>";
		echo "<br />Financial Reporting: <font color=red>" .$row1['question2q3']."</font>";
		echo "<br />Invoicing & Billing: <font color=red>" .$row1['question2q4']."</font>";
		echo "<br />Scheduling: <font color=red>" .$row1['question2q5']."</font>";
		echo "<br />Other:<br /><table width=\"825\" height=\"85\" border=\"1\" bordercolor=\"#000000\">";
		echo "<tr>";
		echo "<td valign=\"top\">";
		echo "<font color=red>" .$row1['question2q6']."</font>";
		echo "</td>";
		echo "</tr>";
		echo "</table>"; }?>
		<!-- Question 4 -->
		<p>4. Please rank these in order of importance (1,2,3,4,5) with #1 the most important, #5 the least important, etc.*
		<br />Tracking projects from field to office more efficiently: <?php while($row3 = mysql_fetch_array($sql3)){ echo "
		<font color=red>".$row3['question4q1']."</font>";
		echo "<br />Tracking one and/or multiple employees\' times to make your company more efficient: <font color=red>".
		$row3['question4q2']."</font>";
		echo "<br />Calculate job profitability on every job in real time at a click of a button: 
		<font color=red>".$row3['question4q3']."</font>";
		echo "<br />Give your clients a way to track jobs, order jobs, and check on invoices and statements without ever calling your 
		office: <font color=red>".$row3['question4q4']."</font>";
		echo "<br />Having a Software solution be 100% customizable to your needs: <font color=red>".$row3['question4q5']."</font>"
		; }?>
		<!-- Question 5 -->
		<p>5. Which would you most likely buy in the next 3-6 months.*
		<?php while($row4 = mysql_fetch_array($sql4)){ 
		echo "<br />A Total Station: <font color=red>".$row4['question5q1']."</font>";
		echo "<br />Project Management Software: <font color=red>".$row4['question5q2']."</font>";
		echo "<br />A TDS Recon: <font color=red>".$row4['question5q3']."</font>";
		echo "<br />Consulting for your company (teaches your company more efficient surveying & engineering techniques): <font 
		color=red>".$row4['question5q4']."</font>";
		echo "<br />Accounting and Payroll Software: <font color=red>".$row4['question5q5']."</font>";
		echo "<br />Other:<br /><table width=\"825\" height=\"85\" border=\"1\" bordercolor=\"#000000\">";
		echo "<tr>";
		echo "<td valign=\"top\"><font color=red>".$row4['question5q6']."</font>";
		echo "</td>";
		echo "</tr>";
		echo "</table>"; }?>
		<!-- Question 6 -->
		<p>6. Would you be interested in Independent Reviews of various project management software programs designed specifically for
		surveyors and engineers?*
		<?php while($row5 = mysql_fetch_array($sql5)){
		echo " <font color=red>".$row5['question6']."</font>";
		//<!-- Question 7 -->
		echo "<p>7. If you answered ‘Yes’ to question 6 -- How interested?";
		echo " <font color=red>".$row5['question7']."</font>";
		//<!-- Question 8 -->
		echo "<p>\"The first rule of any technology used in a business is that automation applied to an efficient operation will 
		magnify the efficiency.\" - Bill Gates"; 
		echo "<br>8. Research has shown that implementing a project management program into an efficient firm can save $15,000 to
		$45,000 a year in company expenses. Would you be interested in a program that can do this?*";
		echo " <font color=red>".$row5['question8']."</font>";
		//<!-- Question 9 -->
		echo "<p>9. If you answered ‘Yes’ to question 8 -- What would be the best day to contact you and go over a 30 minute 
		demonstration?*";
		echo " <font color=red>".$row5['question9']."</font>";}?>
		<table align="center">
			<tr>
				<td><?php
// Figure out the total number of results in DB: 
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM contactinfo"),0); 

// Figure out the total number of pages. Always round up using ceil() 
$total_pages = ceil($total_results / $max_results); 

// Build Page Number Hyperlinks 
echo "<center><br>Next/Prev Lead<br />"; 

// Build Previous Link 
if($page > 1){ 
    $prev = ($page - 1); 
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> "; 
} 

for($i = 1; $i <= $total_pages; $i++){ 
    if(($page) == $i){ 
        echo "$i "; 
        } else { 
            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "; 
    } 
} 

// Build Next Link 
if($page < $total_pages){ 
    $next = ($page + 1); 
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>"; 
} 
echo "</center>"; 
?>
<div align="right">
<script language="Javascript1.2">
<!--

var message = "Print this Lead";

function printpage() {
window.print();  
}

document.write("<form><input type=button "
+"value=\""+message+"\" onClick=\"printpage()\"></form>");

//-->
</script>
</div></td></tr></table>
	</td>
</tr>
</table>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.