|
-
May 19th, 2010, 04:47 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] new to php mysql
hi all
ive setup a sql db and php server.
ive never used it before. i like to use ms access. so new ground for me... and i must say its faster and lest of a hassle keeping track of everything.
i have managed to get a list of everything on the database list but now i want to filter out out stuff. (make the list smaller and what i need.
i have posted my basic connection with shanged password and user info.
can anyone help 
PHP Code:
<html>
<head><title>video list basic</title>
<style type="text/css">
td {font-family: tahoma, arial, verdana; font-size: 10pt }
</style>
</head>
<body>
<?php
/* Change next two lines */
$db="vdidb";
$link = mysql_connect('localhost: 3306', 'youruser', 'your password');
if (! $link)
die(mysql_error());
mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());
// $result = mysql_query( "SELECT vidnumber, videotitle, age, Runningtime, starring, hd, trilogy FROM videolist")
$id = "%".$_GET["search"]."%";
$result = mysql_query( "SELECT vidnumber, videotitle, age, Runningtime, werestoredFolder FROM videolist")
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "There are $num_rows records.<P>";
print "<table width=200 border=1>\n";
while ($get_info = mysql_fetch_row($result)){
print "<tr>\n";
foreach ($get_info as $field)
print "\t<td>$field</td>\n";
print "</tr>\n";
}
print "</table>\n";
mysql_close($link);
?>
<br>
</body>
</html>
programming pc: laptop. running xp pro and vb.net..
media centre xp pc: dual core 6000,4gb memory, 1tb harddrive
mainserver: server 2008, 8gb memory, amd e-350 dual core, 6tb harddrive and local web host
atomvault 1: server 2008, atom 330 with 4 gb memory, 35TB hardrive space for videos and music..
backup pc : xp, 4gb, atom 330, 10tb harddrive(web, pictures, music, databases)
2 x video backup: atom 330, 2gb, 18tb harddrive
everything on remote login..
check out my builds http://AtomVaults.yolasite.com
learning vb.net and php + mysql   - got most of the basics now.
I WISH THERE WAS MORE TIME IN THE DAY  
-
May 19th, 2010, 05:58 PM
#2
Re: new to php mysql
One possible example:
Code:
$id = "%".$_GET["search"]."%";
$result = mysql_query( "SELECT vidnumber, videotitle, age, Runningtime, werestoredFolder FROM videolist WHERE videotitle LIKE '".mysql_real_escape_string($id)."'")
You can read up on the MySQL SELECT syntax over here, which details how to manipulate your query results. The LIKE clause in particular tries to match a pattern to column content. The % is a wild-card symbol, and $_GET["search"] is populated with whatever the value of the variable "search" is in the URL's query string. So, if you accessed the page as http://localhost/mypage.php?search=video then $id = "%video%", and the query will try to find a record where videotitle has "video" within it.
You can add additional SQL conditions and variables to your query to further filter the data as desired. Have a look at the provided links and then ask any questions you've got.
-
May 20th, 2010, 10:33 AM
#3
Thread Starter
Hyperactive Member
Re: new to php mysql
thanks for that sambaneko, i spent most of the night trying to work it out..
im want to add a input box and action button for the search on the page at the top
i found this on the web but not sure how to put it all together
PHP Code:
<body>
<form method="post" action="thanks.php">
<input type="text" name="test1">
<input type="submit" value="Process">
</form>
</body>
</html>
programming pc: laptop. running xp pro and vb.net..
media centre xp pc: dual core 6000,4gb memory, 1tb harddrive
mainserver: server 2008, 8gb memory, amd e-350 dual core, 6tb harddrive and local web host
atomvault 1: server 2008, atom 330 with 4 gb memory, 35TB hardrive space for videos and music..
backup pc : xp, 4gb, atom 330, 10tb harddrive(web, pictures, music, databases)
2 x video backup: atom 330, 2gb, 18tb harddrive
everything on remote login..
check out my builds http://AtomVaults.yolasite.com
learning vb.net and php + mysql   - got most of the basics now.
I WISH THERE WAS MORE TIME IN THE DAY  
-
May 20th, 2010, 12:06 PM
#4
Re: new to php mysql
.. if all you're asking is how to make a form, then you've already done it. you have an input text and a button; that's all you really need.
where is the rest of your code that you 'tried to work out'? for example, the 'thanks.php' script.
-
May 20th, 2010, 12:37 PM
#5
Thread Starter
Hyperactive Member
Re: new to php mysql
hi
the code below was found on the net just using a quick google search
sorry wasnt that clear, im want to search for a video using the input section(video title) and actioning the search from the button
to make it easyier to search
thanks.php is from the online sample
PHP Code:
<body>
<form method="post" action="thanks.php">
<input type="text" name="test1">
<input type="submit" value="Process">
</form>
</body>
</html>
programming pc: laptop. running xp pro and vb.net..
media centre xp pc: dual core 6000,4gb memory, 1tb harddrive
mainserver: server 2008, 8gb memory, amd e-350 dual core, 6tb harddrive and local web host
atomvault 1: server 2008, atom 330 with 4 gb memory, 35TB hardrive space for videos and music..
backup pc : xp, 4gb, atom 330, 10tb harddrive(web, pictures, music, databases)
2 x video backup: atom 330, 2gb, 18tb harddrive
everything on remote login..
check out my builds http://AtomVaults.yolasite.com
learning vb.net and php + mysql   - got most of the basics now.
I WISH THERE WAS MORE TIME IN THE DAY  
-
May 20th, 2010, 09:33 PM
#6
Thread Starter
Hyperactive Member
Re: new to php mysql
hi
i solved my problem after playing around with querys doing somthing else
PHP Code:
<body>
<form method="query" action="mysql2.php">
<input type="number" name="search">
<input type="submit" value="get videos">
</form>
</body>
</html>
i changed method to query and name to search
programming pc: laptop. running xp pro and vb.net..
media centre xp pc: dual core 6000,4gb memory, 1tb harddrive
mainserver: server 2008, 8gb memory, amd e-350 dual core, 6tb harddrive and local web host
atomvault 1: server 2008, atom 330 with 4 gb memory, 35TB hardrive space for videos and music..
backup pc : xp, 4gb, atom 330, 10tb harddrive(web, pictures, music, databases)
2 x video backup: atom 330, 2gb, 18tb harddrive
everything on remote login..
check out my builds http://AtomVaults.yolasite.com
learning vb.net and php + mysql   - got most of the basics now.
I WISH THERE WAS MORE TIME IN THE DAY  
-
May 20th, 2010, 09:43 PM
#7
Re: [RESOLVED] new to php mysql
err. method="query" is not valid. if you want to have your form variables be available to the query string, your method should be "get." your form only works because if the browser doesn't know what method you're trying to use, it will use get by default.
-
May 21st, 2010, 09:52 AM
#8
Thread Starter
Hyperactive Member
Re: [RESOLVED] new to php mysql
hi kows
i have now changed it to get.
im learning this php stuff as i go. thank again
programming pc: laptop. running xp pro and vb.net..
media centre xp pc: dual core 6000,4gb memory, 1tb harddrive
mainserver: server 2008, 8gb memory, amd e-350 dual core, 6tb harddrive and local web host
atomvault 1: server 2008, atom 330 with 4 gb memory, 35TB hardrive space for videos and music..
backup pc : xp, 4gb, atom 330, 10tb harddrive(web, pictures, music, databases)
2 x video backup: atom 330, 2gb, 18tb harddrive
everything on remote login..
check out my builds http://AtomVaults.yolasite.com
learning vb.net and php + mysql   - got most of the basics now.
I WISH THERE WAS MORE TIME IN THE DAY  
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|