[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Doing a comparison of records

Posted on 2008-01-31
6
Medium Priority
?
225 Views
Last Modified: 2012-05-05
Good evening, I was wondering how someone would go about comparing multiple records on a web page. For example:

If a page has 10 records on it and there was a checkbox next to each record. If 3 of the boxes where checked and someone clicked next they would be sent to a page that would compare those 3 records side by side with any of the informaiton from the database.

If this is extremely difficult please let me know ahead of time. I am hoping someone has an example to show me how to do this. If not just let me know. Thank you for your time and have a great evening.

Rob
0
Comment
Question by:pertrai1
  • 4
  • 2
6 Comments
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 20794193
what i could understand from you questions is, from the 10 records you select 3 records and take it to next page ... here want to compare with db these 3 records??? am i correct?
0
 

Author Comment

by:pertrai1
ID: 20795851
Yes that is exactly what I want to do
0
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 20795961
i assume in the page1.php ... check box contains (like mail in box display)....

<form name="frm1" method="post">
...
<INPUT TYPE="checkbox" NAME="s[]" VALUE="A" CHECKED>Checkbox 1<BR>
<INPUT TYPE="checkbox" NAME="s[]" VALUE="B">Checkbox 2<BR>
<INPUT TYPE="checkbox" NAME="s[]" VALUE="C">Checkbox 3<BR>
...
</form>


process.page ... just print ....

<?php

print_r ($_POST);

also , it will display

the same PHP code will produce the output below:

(array)
Array (
    [0] => A
    [1] => B
    [2] => C


<< loop it all the records (10)>>
// loop through the array and process index key values
check single value with == db connected value ..

do the process...


)

?>

more detailed at,

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/PHP_Databases/Q_23003732.html

   1.
      <body>
   2.
      <form action="checkbox.php" method="post">
   3.
        <input type="checkbox" name="checkbox[]" value="a">
   4.
        <input type="checkbox" name="checkbox[]" value="b">
   5.
        <input type="checkbox" name="checkbox[]" value="c">
   6.
        <input type="checkbox" name="checkbox[]" value="d">
   7.
        <br>
   8.
        <br>
   9.
        <input type="submit" name="Submit" value="Submit">
  10.
      </form>
  11.
      <?
  12.
       
  13.
      /* and in your checkbox.php you do this: */
  14.
       
  15.
      if(isset($_POST['Submit']))
  16.
      {
  17.
          for ($i=0; $i<count($_POST['checkbox']);$i++) {
  18.
             echo "<br />value $i = ".$_POST['checkbox'][$i];
  19.
          }
  20.
      }
  21.
      ?>
  22.
      </body>

Open in new window

0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 20795965
>> in the process loop again you have to connect the DB value and get it checked with these selected items..
0
 

Author Comment

by:pertrai1
ID: 20796084
logudotcom, you have me going on the right track. Now just to make sure I can do this right, let's say that each record in the database has the fields name, age, position, class and I want all of these values to be shown for each checkbox that is clicked, side by side on the checkbox page, what would I need to do this. I can see passing one value for each checkbox, but how about all of the information for each record. Thank you for your help.

Rob
0
 
LVL 36

Accepted Solution

by:
Loganathan Natarajan earned 2000 total points
ID: 20797069
I want all of these values to be shown for each checkbox that is clicked,

>> It could be shown as we display the check boxes ... look at the code attached...



I can see passing one value for each checkbox, but how about all of the information for each record.

>> do you want to see those entire values in another page???


<form action="checkbox.php" method="post">
 
<? for ($i=0; $i <= $rowcount_rs_user; $++) { ?>
 
<input type="checkbox" name="checkbox[]" value="<?<?=$rs_user[$i]["id"]?>?>"><?=$rs_user[$i]["name"]?> <?=$rs_user[$i]["age"]?>  <?=$rs_user[$i]["position"]?> <?=$rs_user[$i]["class"]?>
 
<? } ?>
 
<input type="submit" name="Submit" value="Submit">
 
</form>

Open in new window

0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question