Hi,

I want to create script like in facebook.

When we log into facebook, go into any friend's profile

Their gift button , show gifts with pagination.
when click on image and ok button it save into database.

Any sample demo script ?
How to create script like this?

Please give me suggestions.

Recommended Answers

All 3 Replies

You could do this with radio buttons or JavaScript as facebook does.

Obviously we wont write this script for you but here is how it generally works.

<?php

// Run query to retreive gifts
$get_gifts = mysql_query("SELECT * FROM `gifts`");
if( @mysql_num_rows( $get_gifts ) > 0 ) {
echo "<form method=\"submit\" action=\"#\">";
while( $row = mysql_fetch_array( $get_gifts ) ) {
echo "<img src=\"...\" alt=\"...\" />" . $row['title'] . '<input type="radio" name="gift" value="' . $row['title'] . '" />';
}
echo '<input type="submit" name="send" value="Ok" />';
echo "</form>";
}

if( isset( $_POST['send'] ) ) {
$gift = mysql_real_escape_string( $gift );
// Need the user receiving the gifts id etc.
$user_id = "...";
$query = mysql_query("INSERT INTO `received_gifts` (id, gift) VALUES ('$user_id', '$gift')");
echo "<p>Gift sent</p>";
}

?>

Something allong those general lines.

any demo sample example or script like facebook ?

Or sample link ??

Not that I know of the script above will do the same thing virtually just may need a little playing with.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.