Jump to content

How to look in a database for some info and echo that data


ChrisMartino

Recommended Posts

And... sorry.... to echo that data, here's an example:

 

$strSearch = "Some Text to Search";
$sqlStr = "SELECT * FROM usrtable WHERE usrcolumn LIKE '%".$strSearch."%'";
$sqlRes = mysql_query ($sqlStr, $db);

#Count the number of results
$intRes = mysql_count_results ($sqlRes);

#If there are results
if ($intRes) {

#Loop through the result set
for ($i=0; $i<$intRes; $i++) {

  #Echo all the data
  $strToEcho = mysql_result ($sqlRes, $i, "usrcolumn");
  echo $strToEcho;
}
}

Link to comment
Share on other sites

heres a pic of the table i would like to store the data in is this the right type of colum to store a line of text and echo it?, becasuse the basic idea is every time someone buys a server it saves were there server files are in the database and you echo that data and if they havent got that line in the database (means they havent bought a server) it echos "You currenley have no game servers head over to packages to buy one".

 

dasdsadadas.jpg

Link to comment
Share on other sites

is this something that you are looking for?

 

<?php
$connect = mysql_connect("localhost","username","password") or die ("Couldn't connect");
mysql_select_db("database name") or die ("Couldn't find db");



$query = mysql_query("SELECT * FROM databasename WHERE username='$username'");

$numrows = mysql_num_rows($query);

if ($numrows!=0)
{
  while ($row = mysql_fetch_assoc($query))
  {
$dbhasserver = $row['hassserver'];

  }

if ($dbhasserver = "")
{
echo "You currenley have no game servers head over to packages to buy one.";
}
else
echo $hassserver;

}
else
die("user does not exist");
?>

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.