Jump to content

Simple Dynamic List*


naimenim

Recommended Posts

Hi there, I'm a movie freak and I'm planning of building a simple dynamic movie list. There are some movie lister software available on internet, but I want it lighter and customized. Here is the idea:

 

script.png

 

It looks like yahoo mail inbox...I want to create this script based on php and sql. I think this is the right place where can I get some help. Thanks in advance.

 

NaimeniM

Link to comment
Share on other sites

Do you have any code? How much PHP do you know? what kind of coding model (if any) are you planning on using? Are you just looking for a nudge in the right direction? I understand you are trying to make some kind of movie list, but i'm not sure what you are asking us to do for you.

Link to comment
Share on other sites

Well, I actually don't know php and mysql (very least). I just have the very basic knowledge of php like what's variable, function...

 

I want this script to show the list on a html index page and there will be a php file to make it work and a simple sql database (may be just 3 tables). All I need is to categorize the titles in three or two types. Please, take a look on my idea again. And the matter of fact is I couldn't understand from where to start, that's why I haven't any code written.

 

The list will be just on one page, no pagination..

Link to comment
Share on other sites

Ok, well in that case I would start with your database. How do you want to represent this data in MySQL? What data do you want to store? When searching the database, what information do you think you will be searching on/sorting by? I would then populate the table(s) with some sample data to get you started

 

Afterwards, you can work on the actual meat of the problem. Start with a simple PHP script that will output the list with sample data you populate your table with. From there you can start tying to figure out how to filter the list/sort the list/etc.

 

Having a starting point is the most important thing though. Once you start, you can/should come back here with whatever problems you are having with your code, and we can try our best to help you.

Link to comment
Share on other sites

I should be able to store data by adding individual movie title like "Avatar (2009)" or comma separated titles like "Avatar (2009), Drive (2011), The Smurfs (2011)". The output will be a List like:

 

1. The Smurfs (2011)

2. Drive (2011)

3. Avatar (2009)

 

* The order will be the Latest to Oldest, I mean If I add Drive (2011) yesterday and Avatar (2009) today, the list will look like:

 

1. The Avatar (2009)

2. Drive (2011)

 

Each title should have a Check box with it so that the actions to categorize can be applied to individual or multiples. That's it....

 

Thank you very much for your interest. I'm looking forward to learn some knowledge from the code you will give...

Link to comment
Share on other sites

Thank you very much for your interest. I'm looking forward to learn some knowledge from the code you will give...

We will not write the code for you, there is a freelance section for that.

We WILL give you advice and point you in the right direction, but the onus is on you to get the job done.

 

As mikesta707 said, start with the database, figure out what information you want to store for each movie.

Example fields could be:

title, summary, year, director, rating etc etc

Link to comment
Share on other sites

If you call it freelancing, then I must be somewhere else like freelancer, elance or oDesk. I don't think this is a big deal and I didn't mean to ask you to write me the whole script. I wanted a code of simple list where I would be able to categorize and differentiate them into two or three types. I don't need to add summary, rating, cast, year blah blah...It's not a professional script.

 

If it seems typical to you, then you are not the right person I'm looking for. I know this is a place of php gurus. So, I'm searching the guru who thinks it's easy and who is helpful enough.

 

I could write some initial, but that would be a mess. So, I left it up to you if you think it really simple. Again, I need the structure of the system....not the whole...

 

Come on...

Link to comment
Share on other sites

Would it matter if your code was messy as long as it functioned?

From the way your post was worded, i took that to mean you wanted to read/learn from the code that somebody else has written for you.

 

Regardless, I have written a very BASIC script for you to get your feet wet.

// This is the database structure
CREATE TABLE `movies` (
  `movie_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `movie_name` varchar(100) NOT NULL,
  `movie_added` datetime DEFAULT NULL,
  PRIMARY KEY (`movie_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

 

This next part of the code has NO form for sorting but you can build upon it by adding that function, this code will display the existing records and allow you to add new records.

It has not been tested

// Once the form is submitted the entry will be added into the database //
if (isset($_POST['add'])) {
$sql = "INSERT INTO `movies` (`movie_name`,`movie_added`) VALUES ('".mysql_real_escape_string($_POST['movie_name'])."',NOW())";
if (mysql_query($sql)) {
	echo 'Movie Added'; // Movie added message
} else {
	echo 'Movie not Added'; // Movie not added message
}
}

$sql = "SELECT `movie_id`,`movie_name` FROM `movies` ORDER BY `movie_added` DESC";
$sql_query = mysql_query($sql);
//Make sure there are rows to display
if (mysql_num_rows($sql_query) > 0) {
echo '<table>';
// There are rows, lets loop through and display them with a checkbox
while ($data = mysql_fetch_assoc($sql_query)) {
	echo '<tr>
		<td><input type="checkbox" name="movie_sort[]" value="'.$data['movie_id'].'" /></td>
		<td>'.$data['movie_name'].'</td>
	</tr>';
}
echo '</table>';
} else {
// pretty self explanatory //
echo 'No Movies found.';
}

?>
<!-- This is the form the will be posted to itself -->
<hr/>
<form method="post" action="movies.php">
<strong>Add a new Movie</strong><br/>
<input type="text" name="movie_name" /> <input type="submit" name="add" value="Add Movie" />
</form>

Link to comment
Share on other sites

<?php
$a="Added Successfully";
?>

<script>
function echoHello()
{
<?php hello(); ?>;
}
</script>

<?php
function hello()
{
mysql_query ("INSERT INTO `movies` (`movie_name`,`movie_added`) VALUES ('".mysql_real_escape_string($_POST['movie_name'])."',NOW())");
}
?>

<input type="text" name="movie_name" />
<button onclick="echoHello()">Add</button>

 

I have added this code into movies.php so that I could be able to add a title from this page. But, the text input box can't deliver the tiltle to the database, that is why when I click 'add', a new row is created but without any title. Even, a new row is created by every 'reload" of the page, I mean when I refresh this page, a new blank row is created.

 

I guess, the text input doesn't work because it's in POST method....but I have to use javascript here. So, can you please tell me how to make the input work?FHHDTP

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.