/    Sign up×
Community /Pin to ProfileBookmark

Search DB Table

I need to search just one table, nothing too fancy. Any help would be greatly appreciated!

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@scragarMay 10.2009 — Erm, what kind of database?

I'll assume mysql, since that's the most popular.
[code=php]$con = mysql_connect('HOST', 'USERNAME', 'PASSWORD');
mysql_select_db('DB NAME', $con);

$rs = mysql_query('SELECT * FROM tblname', $con);
while( ! empty( $row = mysql_fetch_assoc($rs) )){
echo "Pulled a row. It's data:";
var_dump($row);
}
[/code]
Copy linkTweet thisAlerts:
@1234567890authorMay 10.2009 — Thanks, however I get the following error

Parse error: syntax error, unexpected '=', expecting ')' in /home/content/z/a/c/zacharyrs20000/html/furniturewebsite/nabokov/search.php on line 6

I am wanting to have a search function for only one table on the database for the user to search.
Copy linkTweet thisAlerts:
@scragarMay 10.2009 — [code=php]$con = mysql_connect('HOST', 'USERNAME', 'PASSWORD');
mysql_select_db('DB NAME', $con);

$rs = mysql_query('SELECT * FROM tblname', $con);
while($row = mysql_fetch_assoc($rs) !== false){
echo "Pulled a row. It's data:";
var_dump($row);
}[/code]

Sorry, I wasn't thinking.
Copy linkTweet thisAlerts:
@1234567890authorMay 11.2009 — Here is my code:

[code=php]<?php
$con = mysql_content ("host", "db", "password");
mysql_select_db('db', $con);


$rs = mysql_query('SELECT * FROM tblname', $con);
while($row = mysql_fetch_assoc($rs) !== false){
echo "Pulled a row. It's data:";
var_dump($row);
}
?>[/code]


And here is the error message:

Fatal error: Call to undefined function mysql_content() in /home/content/z/a/c/zacharyrs20000/html/furniturewebsite/nabokov/search.php on line 2


Any help would greatly be appreciated!
Copy linkTweet thisAlerts:
@scragarMay 11.2009 — mysql_connect != mysql_content
Copy linkTweet thisAlerts:
@1234567890authorMay 11.2009 — mysql_connect != mysql_content[/QUOTE]

I am a php n00b and very un-educated. If you could please tell me where this needs to be in the code I would greatly appreciate it. Sorry ?
Copy linkTweet thisAlerts:
@scragarMay 11.2009 — Sorry, != means not equal to. You've written [B]mysql_content[/B] when you want [B]mysql_connect[/B]. There is no function called [B]mysql_content[/B] which is your error.
Copy linkTweet thisAlerts:
@ryanlundMay 12.2009 — Fail....anyway, what sort of search do you actually want to do....if your trying to do something like an actual search (where you look for text within the database) try google-ing the mysql LIKE condition or full-text searching. I would scrub up my PHP before trying anything like that first though if i was you.
×

Success!

Help @1234567890 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...