/    Sign up×
Community /Pin to ProfileBookmark

Check If Data Is In Column/Table

Hi all,

I’m a newbie to php/mysql but am getting there… I’ve managed to be able to pull some codes from my database… BUT what I want to try and do is to be able to type into a text box, get a result e.g. Yes, the code is in the databse or No, try again… If anyone can give me some ideas on how to do this that’d be great!

[code=php]
<?php

if(empty($_SESSION[‘session_started’]))
{
session_cache_expire(120);
session_start();
$_SESSION[‘session_started’] = “TRUE”;
}

//connect to the mysql database
include ‘configure.php’;
include ‘opendb.php’;

$query = “SELECT Code FROM tblcodes”;
$result = mysql_query($query);

echo ‘<table class=”main” width=”700″ border=”0″ cellspacing=”0″ cellpadding=”0″>
<thead>
<tr>
<th scope=”col” class=”twenty”>CODE ID</th>
<th scope=”col” class=”twenty”>CODE</th>
</tr>
</thead>’;

if (mysql_num_rows($result) < 1) {
echo ‘<tr valign=”top”>
<td colspan=”4″>There are no members that match the query. Please go back and try again</td>
</tr>’;
}

else {
while ($qry = mysql_fetch_array($result)) {

//create the layout
?>
<tr valign=”top”>
<td><?php echo $qry[‘CodeID’]; ?></td>
<td><?php echo $qry[‘Code’]; ?></td>
</tr>
<?php
}
}

echo ‘</table>’;

include ‘closedb.php’;

?>[/code]

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @tomyknoker 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 4.29,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...