!!!!! Posted February 19, 2007 Share Posted February 19, 2007 I am currently learning how Fields work and I am trying to make a little "Search" thingy to search a Table. My Table is called thewwrac?items and I am using PHPMyAdmin to make these Fields. I would like to know: • The Code to search a Table. • How to make the Search Results end up in a list. (If it doesn't do this automatically) • How does the page look when you click on an item from the list of results. (Are the contents of that field in Tables or what.) • Which Type of Field Type can contain Numbers and Letters? If any of my questions are a bit confusing, [which I bet they are], please just ask for a little more info on it... (The Question in a little bit less confusing form.) "Thanks!" Link to comment https://forums.phpfreaks.com/topic/39189-a-few-questions-about-fields/ Share on other sites More sharing options...
boo_lolly Posted February 19, 2007 Share Posted February 19, 2007 here's a quick example: <?php /*connect to the database*/ $db = mysql_connect("xxx", "xxx", "xxx"); mysql_select_db("your_db", $db) OR die("<div align=\"center\"><font color=\"FF0000\"> Sorry, could not connect to the database. Please try again later.</font></div><br />\n"); /*query table*/ $sql = "SELECT column1, column2, column3 FROM your_table"; $query = mysql_query($sql) OR die($sql ."\ncaused the <i>following</i> error:\n". mysql_error()); /*begin results table*/ echo "<table border=\"0\">\n". "\t<tr><th>column 1</th><th>column 2</th><th>column 3</th></tr>". "\t<tr>\n"; /*establish incriment*/ $i = 0; /*populate results*/ while($row = mysql_fetch_array($query)){ $i++; (($i % 3 == 0) ? ("\t</tr>\n\t<tr>") : ("")); echo "<td>". $row['column1'] ."</td><td>". $row['column2'] ."</td><td>". $row['column3'] ."</td>\n"; } /*end table*/ echo "</table>\n"; ?> Link to comment https://forums.phpfreaks.com/topic/39189-a-few-questions-about-fields/#findComment-188761 Share on other sites More sharing options...
!!!!! Posted February 19, 2007 Author Share Posted February 19, 2007 here's a quick example: <?php /*connect to the database*/ $db = mysql_connect("xxx", "xxx", "xxx"); mysql_select_db("your_db", $db) OR die("<div align=\"center\"><font color=\"FF0000\"> Sorry, could not connect to the database. Please try again later.</font></div><br />\n"); /*query table*/ $sql = "SELECT column1, column2, column3 FROM your_table"; $query = mysql_query($sql) OR die($sql ."\ncaused the <i>following</i> error:\n". mysql_error()); /*begin results table*/ echo "<table border=\"0\">\n". "\t<tr><th>column 1</th><th>column 2</th><th>column 3</th></tr>". "\t<tr>\n"; /*establish incriment*/ $i = 0; /*populate results*/ while($row = mysql_fetch_array($query)){ $i++; (($i % 3 == 0) ? ("\t</tr>\n\t<tr>") : ("")); echo "<td>". $row['column1'] ."</td><td>". $row['column2'] ."</td><td>". $row['column3'] ."</td>\n"; } /*end table*/ echo "</table>\n"; ?> Okay, I'll try that. Thanks. Link to comment https://forums.phpfreaks.com/topic/39189-a-few-questions-about-fields/#findComment-188779 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.