0

how we can display records

1-5 for 1 user.
for 2nd user, we can display 2-6
for 3rd user, we can display 3-7
so on...

Edited by pritaeas: Moved to PHP (a guess).

4
Contributors
4
Replies
36
Views
2 Years
Discussion Span
Last Post by mangel.murti
0

i have the same problem too. i want to display a list of records from database when i clicked a button, it will display the list of records of 1 id. but i dont have any idea to do it. can someone help me? T________T

0

Check the below example.

In index.php

<script src="//code.jquery.com/jquery-1.10.2.js"></script>

 <?php

$numberOfUser= 6;
$recordLimit = 5;

?>

<select id="userSelect">
<option value="">---Select User---</option>
<?php
for($i=1;$i<=$numberOfUser;$i++){
    echo <<<EOD
        <option value="$i">User-$i</option>
EOD;
}
?>
</select>


<div class="result">
<h3>Please Select A User</h3>
</div>

<script type="text/javascript">
$(function(){
    $("#userSelect").change(function(){
        var userOrder =$(this).val();
        $.post('request.php',{order: userOrder, numberOfUser: '<?php echo $numberOfUser; ?>', limit: '<?php echo $recordLimit; ?>'}, function(data) {
            $(".result").html(data);
        });
    });
});
</script>

In request.php

<?php
$numberOfUser= $_POST['numberOfUser'];
$recordLimit = $_POST['limit'];

$userOrder = $_POST['order'];


if($userOrder>0) {
//your records
$records = array();
for($i=1;$i<=($recordLimit+($numberOfUser-1));$i++) {
    array_push($records,'R-'.$i);
}

//List Limited Records
$result = "<ul>";

for ($j=($userOrder-1);$j<($recordLimit+($userOrder-1));$j++) {
    $result .= "<li>".$records["$j"]."</li>"; 
}

$result .= "</ul>";
}

else {
    $result = "<h3>Please Select A User</h3>";    
}


echo $result;


?>
0

Thanks all for reply / discussion

I have an offers tables like there are 100 records and user table.

offer table has offer_id, price , offer_type, user_id_fk... etc
user table has user_id, name ...etc

featured offer means with payed amout let say $3.

When user login so all offers i am displaying now.

if i randomly display records then each records will not get equal exposure to dashboard of userlogin

but what i want

Every featured offer should get equal exposure.
If we are displaying 5 feaured offers out of total of 100 feaured offers, then all 100 should get equal exposure. Across all the different featured.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.