Jump to content

Get Data From 1 Table


igotregistered

Recommended Posts

Hi, new guy gettting started with

 

I've been researching and I found a script which works....However, it's pulling every single record. I want the script to parse the "title" column and only retrieve the records of player names.

 

Example

 

The column "title" in the table has "Bob Smith vs John Doe Apr 1, 2012 hockey team vs hockey team". I want only records which have the name "John Doe" in it. I don't want, any records besides John Doe's.

 

I only want my query to find a single name in the title, (not the whole title)

 

So if this is the title : "Bob Smith vs John Doe Apr 1, 2012 hockey team vs hockey team"

 

I only want to find any records in the table related to "John Doe". Nothing else. HOpe that makes sense.

 

Thank you for any help. :)

 

 

<?php
// Make a MySQL Connection
mysql_connect("10.x.xx.xx", "un", "pw") or die(mysql_error());
mysql_select_db("mydbname") or die(mysql_error());

// Get all the data from the "_mytables" table
$result = mysql_query("SELECT * FROM _mytables") 
or die(mysql_error());  


echo "<table border='1'>";
echo "<tr> <th>Fight Matchup</th> <th>Fight Video</th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>"; 
echo $row['title'];
echo "</td><td>"; 
echo $row['link'];
echo "</td></tr>"; 
} 

echo "</table>";
?>

Link to comment
https://forums.phpfreaks.com/topic/271528-get-data-from-1-table/
Share on other sites

Hi @gristoi. Thank you for the reply.

 

So would this be correct?

 

<?php
// Make a MySQL Connection
mysql_connect("10.x.xx.xx", "un", "pw") or die(mysql_error());
mysql_select_db("mydbname") or die(mysql_error());

// Get all the data from the "_mytables" table
$result = mysql_query("SELECT * FROM _mytable where title LIKE "%Bobby Robins%")
or die(mysql_error());


echo "<table border='1'>";
echo "<tr> <th>Fight Matchup</th> <th>Fight Video</th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['title'];
echo "</td><td>";
echo $row['link'];
echo "</td></tr>";
}

echo "</table>";
?>

It's not all of the verbiage in the title I only want the script to pull fights for only one name out of the title, specifically Bobby Robins. Then all of his fights will populate on his own page. Right now my table has 30 thousand various fights from thousands of different fighters.

 

Thank you

The video script I'm using is a custom script which was made by a developer for vbulletin. I paid for it. It's similar to a youtube script. Basically all I have is category, title, description, keywords.

 

That's it. Thats why the names of the players are all mixed in with each other in the title matchups. They're all categorized by the league they play in.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.