PHP - Php/mysql Page Nav And Display.
Hey,
I'm having problems displaying data from a mysql database properly. Problem page: here It's a bit like a cms, a user fills out a form asking for a page title and the page content, thats then stored in the database and the finished result should be the page title added to the navigation and when clicked displaying the relevant page. I don't know if its possible but I'd like it to be done all on the one page. As you can see on the link I provided, when you click more than one link it displays it on the same page, rather than replacing itself. Can you help with this? Code: <html> <head> <script> function show_content(id){ document.getElementById(id).style.display='block'; } </script> </head> <body> <font face=verdana size=1> <?php include 'dbwire.php'; $query = mysql_query('SELECT * FROM content'); while($results = mysql_fetch_array($query,MYSQL_ASSOC)){ $title = $results['title']; $id = $results['id']; $content = $results['content']; echo "| <a href=\"javascript:void(0);\" onclick=\"show_content($id)\">$title</a> "; echo "<div id=\"$id\" style=\"display:none\">$content</div>"; } ?> <hr> </body> </html> Also, any idea how I should do the navigation? As you can see the more pages added the longer the navigation will get...eventually extending beyond the page width and creating problems. I understand I have problems explaining, if you need more just let me know! Thanks, Drew. Similar TutorialsHi, Wonder if someone could help with the problem below. Got a main page that includes a header, footer and a link to a database. I can get the two Includes to work but can't seem to display the database fields in the body of the page. What has me baffled is that it appears to be connecting to the database, (Opening the connection to the database server The connection worked. The link is: Resource id #3) but no text (see below for database text) is appearing on the screen. Yet I'm not getting a "page_not_found" message. I can go to the database in MYSQL console and query it successfully. Read and (hopefully) applied the section Debugging: A Beginner's Guide, but still can't see the problem. Any help greatly appreciated. Bren --------------------CODE FOR MAIN PAGE START------------------- <?php $page_name = $_REQUEST['name']; /*http://localhost/exemples/page.php?name=about_us*/ // Get the body of the page mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("test") or die(mysql_error()); $sql = "SELECT * from pages WHERE name='$page_name'"; print "Opening the connection to the database server<br>"; $link = mysql_connect("localhost","root", ""); print "The connection worked. The link is: $link <br>"; /* --------------What is being selected from the database-------------- +----------+------------------------------------------------------------------------+ | name | body | +----------+------------------------------------------------------------------------+ | about_us | <h1>About Us</h1> ACME Toys has been established in 1850 to provide toys | to children all over the world +----------+------------------------------------------------------------------------+ 1 row in set (0.00 sec) ---------------------------------------------------------------------- */ $result = mysql_query($sql) or die(mysql_error() ); // If the page is not found, redirect to a static page if(mysql_num_rows($result) == 0 ) { header("Location: page_not_found.html"); } $row = mysql_fetch_assoc( $result ); $body = stripslashes( $row["body"] ); // Include the header include("c:/wamp/www/exemples/header.php"); // Print the body of the page echo $body; // Include the footer include("c:/wamp/www/exemples/footer.php"); ?> --------------------CODE FOR MAIN PAGE END------------------- Hi I have tried and tried and tried again to get this to work
in simple terms I have very little knowledge with PHP and even less with mysql
I have a paid subscription and domain in order to learn more and I feel I have made ok progress so far
then I realised how unsafe my current work is;
here is my experience this far
I created a site for a group of voluntary online game hosts where they can posts points from their tournaments in a forum
and some info pages to go with this,
however what I did was create a base template and style sheet and then an admin dashboard linked to individual forms to allow the group admin to edit the info pages they go to my form and enter the desired info and submit this then sends through and action file which posts the text and <BR> to a .txt file,
then the connecting page reads the .txt file using the PHP code of " <? php include ( 'index.txt'); ?>
yes you are seeing this correctly I have allowed a direct edit of text in a .txt file rather silly of me but I didn't realise how unsafe this was until now I guess its a good job I trust that the admin has no knowledge or skills in coding
ok since all this I have created a DB in MySQL on my server,
My server uses PHPMyAdmin I have create a DB named " mnvbcou1_content1 " and a table named " home " with rows " ID " and " home "
what I am trying to do:
I want my page to display the content of the table row home and a form once submitted to send to the table row home
or if needed I can re make this DB if the names are not suitable
I have tried to create the needed coding to make this work but for some reason this just will not work I have already added 2 rows to my table to try and make the page to display the content but it just is not working I got an error every time
so I hope that someone out there is rather patient and is willing to help me learn how to do this correctly and safely,
also this is a closed group website the address to this site is only known by a handful of none programmers I am mainly trying to make this work for my own personal knowledge and server safety please help me
My Php Buddies, I have mysql tbl columns these:
id: Now, I want to display their row data by excluded a few columns. Want to exclude these columns: date_&_time account_activation_code account_activation_status id_verification_video_file_url password
So, the User's (eg. your's) homepage inside his account should display labels like these where labels match the column names but the underscores are removed and each words' first chars CAPITALISED:
Id: 1
For your convenience only PART 1 works. Need help on Part 2 My attempted code:
PART 1 <?php // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // Query to get columns from table $query = $conn->query("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'members' AND TABLE_NAME = 'users'"); while($row = $query->fetch_assoc()){ $result[] = $row; } // Array of all column names $columnArr = array_column($result, 'COLUMN_NAME'); foreach ($columnArr as $value) { echo "<b>$value</b>: ";?><br><?php } ?> PART 2 <?php //Display User Account Details echo "<h3>User: <a href=\"user.php?user=$user\">$user</a> Details</h3>";?><br> <?php $excluded_columns = array("date_&_time","account_activation_code","account_activation_status","id_verification_video_file_url","password"); foreach ($excluded_columns as $value2) { echo "Excluded Column: <b>$value2</b><br>"; } foreach ($columnArr as $value) { if($value != "$value2") { $label = str_replace("_"," ","$value"); $label = ucwords("$label"); //echo "<b>$label</b>: "; echo "$_SESSION[$value]";?><br><?php echo "<b>$label</b>: "; echo "${$value}";?><br><?php } } ?> PROBLEM: Columns from the excluded list still get displayed. Edited November 19, 2018 by phpsanehey just curious if i could pull this off some how <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("database", $con); $result = mysql_query("SELECT title FROM table1"); foreach($result) { ?> <div><?php echo title; ?> </div> <?php mysql_close($con); ?> Basicly im trying to query the database and foreach result display it within divs? ive been trying to figure it out for a while and im stuck any help would be awsome thanks Hello everyone, I need help figuring out why im not getting images displayed. I have tried everything I could think of and narrowed down the issue. What Im doing id querying urls from DB for my images. Then using md5 to encrypting the url them before display on web page. Here is the code: Code: [Select] $img = @ md5(mysql_result(mysql_query("SELECT `url` FROM `pictures` WHERE `mls`='{$row['mls']}' ORDER BY `id` LIMIT 1",$avenu->link),0)); When html is displayed I get the hash.jpg. The image failed to be loaded. hello all, I am using the following code to retrieve mysql data and show on my page.. Code: [Select] <?php include "dbconnect.php"; $link=dbconnect(); $result = mysql_query("SELECT * FROM playlist where date= '2011-09-06'") or die(mysql_error()); echo "<table width = 100% border = '0' cellspacing = '2' cellpadding = '0'>"; while ($friendList = mysql_fetch_array($result)) { echo "<tr>" . "<td><a href='memberindex.php?id = ".$friendList['id']."'><img src='".$friendList['image']."' title='".$friendList['artist']."' alt='".$friendList['album']."'/><br />".$friendList['album']."</a><br /></td> " . "</tr> "; } echo "</table> "; ?> this code retrieve image and album name from the table and display as below: id 1 image1 album1 id 2 image2 album2 id 3 image3 album3 but i want to display the info as below: id1-----------------id2---------------id3 image1------------image2-----------image3 album1------------album2-----------album3 i want image and album name of a product as column but other product as rows. I hope you understand. anyone can help me with this please? I am managing a shop website which is using php and mysql for data. The website has a section that will display the related products with the one that you are watching. Now my problem is that if there are more than 5 items it will continue to display all the items in one row with the consequent that the page will not display well. I need to find a way to begin a new row after the 5th item so it will display 5 items in each row. this is my current code that is responsible for showing the related items. There is also a picture attached with the problem. while ($row = mysql_fetch_array($retd)) { $code = $row["code"]; $name = $row["name"]; echo("<td width=150 align=center>"); echo ("<a href=../products/info.php?scode=$code><img src=pictures/$code.gif border=0 alt=Item $name</a>"); echo ("<br><a href=../products/info.php?scode=$code><span class=fs13>$name</span></a>"); echo("</td>"); } Does anyone know how can I do this? I am trying to display a single value on my page and i cant seem to display it for the life of me. can someone tell me if im doing something wrong? this is what i have so far: <?php require_once('inc/common.inc.php'); // Connect to the database db_connect(); // Check and update the authentication. check_auth(); db("select * from ${db_name}_users where login_id = '$login_id'"); echo "$login_id"; ?> obviously there is a field in the database that corresponds to turns and it is int(4), ..... Now, i am able to display $login_id, but when i try to display another field, named turns, it just displays a blank page. Any pointers would be appreciated thank you. I'm not sure what I'm doing wrong here... This is my index <html <head> <title>Admin applications</title> </head> <body text="#000000"> <center> <?php include("connect.php"); echo "<table cellpadding='3' cellspacing='2' summary='' border='3'>"; echo "<tr><td>Real name:<br><br>"; echo $row['real_name']; echo "</td><td>Age:<br><br>"; echo $row['age']; echo "</td><td>In-Game Name:<br><br>"; echo $row['game_name']; echo "</td><td>Steam ID:<br><br>"; echo $row['steamid']; echo "</td><td>Agreement:<br><br>"; echo $row['agreement']; echo "</td><td>Will use vent:<br><br>"; echo $row['vent']; echo "</td><td>Activity:<br><br>"; echo $row['activity']; echo "</td><td>Why this person wants to be an admin:<br><br>"; echo $row['why']; echo "</td></tr></table>"; ?> </center> </body> </html> and this is my database connect <?php $database="admin"; mysql_connect ("localhost", "root", "waygan914"); @mysql_select_db($database) or die( "Unable to select database"); mysql_query("SELECT * FROM applications"); ?> The database table "applications" has 8 fields, and 2 records, but when I view the page i get the table but no data: Hi, Is it possible to build a PHP Template page that selects and publishes a row of data from a MySQL Database when a linked is clicked? I would design: Template.php Text links (perhaps on homepage of navigation bar): ProductA, ProductB and ProductC If you click link ProductA Template.php would display data for ProductA and likewise for ProductB and ProductC. I would also like search engines for find ProductA, ProductB and ProductC PHP pages. (Not just my single Template.php) Any ideas as to how this could be done without designing individual PHP pages for each product? Kind regards, Matthew. I have a database with one row and about 50 columns, where the inserted data is being displayed on a page. But a lot of the time not all columns are being used. So say only 25 columns have data, there will be 25 blanks spaces with an • symbol. Is there a way to ignore to columns that have no data in them? Such as SELECT * from notices WHERE [columns have data] Code: [Select] <?php $html="<table>"; $q="select * from notices"; $r=mysql_query($q); while($o=mysql_fetch_object($r)){ foreach($o as $key=>$val){ $html.="<tr><td colspan='2' bgcolor='#896B45'><div style='padding:10px;'>&#8226; {$val}<br></div></td></tr>"; }} $html.="</table>"; echo $html; ?> CREATE TABLE `notices` ( `id` int(11) NOT NULL auto_increment, `notice1` text, `notice2` text, `notice3` text, `notice4` text, `notice5` text, `notice6` text, `notice7` text, `notice8` text, `notice9` text, `notice10` text, `notice11` text, `notice12` text, `notice13` text, `notice14` text, `notice15` text, `notice16` text, `notice17` text, `notice18` text, `notice19` text, `notice20` text, `notice21` text, `notice22` text, `notice23` text, `notice24` text, `notice25` text, `notice26` text, `notice27` text, `notice28` text, `notice29` text, `notice30` text, `notice31` text, `notice32` text, `notice33` text, `notice34` text, `notice35` text, `notice36` text, `notice37` text, `notice38` text, `notice39` text, `notice40` text, `notice41` text, `notice42` text, `notice43` text, `notice44` text, `notice45` text, `notice46` text, `notice47` text, `notice48` text, `notice49` text, `notice50` text, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=40 DEFAULT CHARSET=utf8 I have an admin page for the posting of the date to the database: Code: [Select] <?php include_once($_SERVER["DOCUMENT_ROOT"] . "/main.inc.php"); $page_content = db_select("select * from notices"); $pc = $page_content[0]; $ff=$_POST; if ($ff['submit']) { $insc="UPDATE notices SET notice1='".$ff['notice1']."' , notice2='".$ff['notice2']."' , notice3='".$ff['notice3']."' , notice4='".$ff['notice4']."' , notice5='".$ff['notice5']."' , notice6='".$ff['notice6']."' , notice7='".$ff['notice7']."' , notice8='".$ff['notice8']."' , notice9='".$ff['notice9']."' , notice10='".$ff['notice10']."' , notice11='".$ff['notice11']."' , notice12='".$ff['notice12']."' , notice13='".$ff['notice13']."' , notice14='".$ff['notice14']."' , notice15='".$ff['notice15']."' , notice16='".$ff['notice16']."' , notice17='".$ff['notice17']."' , notice18='".$ff['notice18']."' , notice19='".$ff['notice19']."' , notice20='".$ff['notice20']."' , notice21='".$ff['notice21']."' , notice22='".$ff['notice22']."' , notice23='".$ff['notice23']."' , notice24='".$ff['notice24']."' , notice25='".$ff['notice25']."' , notice26='".$ff['notice26']."' , notice27='".$ff['notice27']."' , notice28='".$ff['notice28']."' , notice29='".$ff['notice29']."' , notice30='".$ff['notice30']."' , notice31='".$ff['notice31']."' , notice32='".$ff['notice32']."' , notice33='".$ff['notice33']."' , notice34='".$ff['notice34']."' , notice35='".$ff['notice35']."' , notice36='".$ff['notice36']."' , notice37='".$ff['notice37']."' , notice38='".$ff['notice38']."' , notice39='".$ff['notice39']."' , notice40='".$ff['notice40']."' , notice41='".$ff['notice41']."' , notice42='".$ff['notice42']."' , notice43='".$ff['notice43']."' , notice44='".$ff['notice44']."' , notice45='".$ff['notice45']."' , notice46='".$ff['notice46']."' , notice47='".$ff['notice47']."' , notice48='".$ff['notice48']."' , notice49='".$ff['notice49']."' , notice50='".$ff['notice50']."' , id='1' WHERE id='1'"; mysql_query($insc); } ?> <html> <head> </head> <body> <form name="noticesform" method="post" action="notices_admin.php" enctype="multipart/form-data"> <textarea name='notice1' cols='110' rows='3' class='input'><?=$pc["notice1"]?> </textarea> <textarea name='notice2' cols='110' rows='3' class='input'><?=$pc["notice2"]?> </textarea> <textarea name='notice3' cols='110' rows='3' class='input'><?=$pc["notice3"]?> </textarea> <textarea name='notice4' cols='110' rows='3' class='input'><?=$pc["notice4"]?> </textarea> <textarea name='notice5' cols='110' rows='3' class='input'><?=$pc["notice5"]?> </textarea> <textarea name='notice6' cols='110' rows='3' class='input'><?=$pc["notice6"]?> </textarea> <textarea name='notice7' cols='110' rows='3' class='input'><?=$pc["notice7"]?> </textarea> <textarea name='notice8' cols='110' rows='3' class='input'><?=$pc["notice8"]?> </textarea> <textarea name='notice9' cols='110' rows='3' class='input'><?=$pc["notice9"]?> </textarea> <textarea name='notice10' cols='110' rows='3' class='input'><?=$pc["notice10"]?> </textarea> <textarea name='notice11' cols='110' rows='3' class='input'><?=$pc["notice11"]?> </textarea> <textarea name='notice12' cols='110' rows='3' class='input'><?=$pc["notice12"]?> </textarea> <textarea name='notice13' cols='110' rows='3' class='input'><?=$pc["notice13"]?> </textarea> <textarea name='notice14' cols='110' rows='3' class='input'><?=$pc["notice14"]?> </textarea> <textarea name='notice15' cols='110' rows='3' class='input'><?=$pc["notice15"]?> </textarea> <textarea name='notice16' cols='110' rows='3' class='input'><?=$pc["notice16"]?> </textarea> <textarea name='notice17' cols='110' rows='3' class='input'><?=$pc["notice17"]?> </textarea> <textarea name='notice18' cols='110' rows='3' class='input'><?=$pc["notice18"]?> </textarea> <textarea name='notice19' cols='110' rows='3' class='input'><?=$pc["notice19"]?> </textarea> <textarea name='notice20' cols='110' rows='3' class='input'><?=$pc["notice20"]?> </textarea> <textarea name='notice21' cols='110' rows='3' class='input'><?=$pc["notice21"]?> </textarea> <textarea name='notice22' cols='110' rows='3' class='input'><?=$pc["notice22"]?> </textarea> <textarea name='notice23' cols='110' rows='3' class='input'><?=$pc["notice23"]?> </textarea> <textarea name='notice24' cols='110' rows='3' class='input'><?=$pc["notice24"]?> </textarea> <textarea name='notice25' cols='110' rows='3' class='input'><?=$pc["notice25"]?> </textarea> <textarea name='notice26' cols='110' rows='3' class='input'><?=$pc["notice26"]?> </textarea> <textarea name='notice27' cols='110' rows='3' class='input'><?=$pc["notice27"]?> </textarea> <textarea name='notice28' cols='110' rows='3' class='input'><?=$pc["notice28"]?> </textarea> <textarea name='notice29' cols='110' rows='3' class='input'><?=$pc["notice29"]?> </textarea> <textarea name='notice30' cols='110' rows='3' class='input'><?=$pc["notice30"]?> </textarea> <textarea name='notice31' cols='110' rows='3' class='input'><?=$pc["notice31"]?> </textarea> <textarea name='notice32' cols='110' rows='3' class='input'><?=$pc["notice32"]?> </textarea> <textarea name='notice33' cols='110' rows='3' class='input'><?=$pc["notice33"]?> </textarea> <textarea name='notice34' cols='110' rows='3' class='input'><?=$pc["notice34"]?> </textarea> <textarea name='notice35' cols='110' rows='3' class='input'><?=$pc["notice35"]?> </textarea> <textarea name='notice36' cols='110' rows='3' class='input'><?=$pc["notice36"]?> </textarea> <textarea name='notice37' cols='110' rows='3' class='input'><?=$pc["notice37"]?> </textarea> <textarea name='notice38' cols='110' rows='3' class='input'><?=$pc["notice38"]?> </textarea> <textarea name='notice39' cols='110' rows='3' class='input'><?=$pc["notice39"]?> </textarea> <textarea name='notice40' cols='110' rows='3' class='input'><?=$pc["notice40"]?> </textarea> <textarea name='notice41' cols='110' rows='3' class='input'><?=$pc["notice41"]?> </textarea> <textarea name='notice42' cols='110' rows='3' class='input'><?=$pc["notice42"]?> </textarea> <textarea name='notice43' cols='110' rows='3' class='input'><?=$pc["notice43"]?> </textarea> <textarea name='notice44' cols='110' rows='3' class='input'><?=$pc["notice44"]?> </textarea> <textarea name='notice45' cols='110' rows='3' class='input'><?=$pc["notice45"]?> </textarea> <textarea name='notice46' cols='110' rows='3' class='input'><?=$pc["notice46"]?> </textarea> <textarea name='notice47' cols='110' rows='3' class='input'><?=$pc["notice47"]?> </textarea> <textarea name='notice48' cols='110' rows='3' class='input'><?=$pc["notice48"]?> </textarea> <textarea name='notice49' cols='110' rows='3' class='input'><?=$pc["notice49"]?> </textarea> <textarea name='notice50' cols='110' rows='3' class='input'><?=$pc["notice50"]?> </textarea> <input type="submit" name="submit" value="Click here to update" class="input"> </form> </body> </html> I have a 'user' table and a display users page. How would I display them in alphabetical order by their username? Heres my current basic display page: <?php include 'dbwire.php'; include 'header.php'; $query = mysql_query('SELECT * FROM user'); while ($row = mysql_fetch_array($query)) { echo '<b>Username:</b> ' . $row['user'] . '<br />'; echo '<b>Real Name:</b> ' . $row['name'] . '<br />'; echo '<b>Email:</b> ' . $row['email'] . '<br />'; echo '<b>Location:</b> ' . $row['location'] . '<br /> <hr>'; } ?> Theres also an id row but since user wouldn't be added alphabetically I wouldn't be able to order them by id. Hi, I am having an issue with displaying an image that is uploaded in a mysql database. The table format is ----------------------------------------------------------- | id | name | mime | size | data | ----------------------------------------------------------- | 1 | test | image/jpeg| 74857 | BLOB | The data has uploaded fine. I then have the following script on my 'displayimage.php?imgid=1' page... Code: [Select] $id = $_GET['imgid']; $result = mysql_query("SELECT * FROM images WHERE id = '$id'"); while($row = mysql_fetch_array($result)) $size = $row['size']; $mime = $row['mime']; $name = $row['name']; { header("Content-length: $size"); header("Content-type: $mime"); header("Content-Disposition: attachment; filename=$name"); echo $row['data']; However everytime i try to open this page, Firefox or Internet Explorer just ask's me to try and download the file as a php file. Any ideas what is going wrong? Thanks! Matt Morning all, and Evening everyone else. Im using the following Query to display information from a table Code: [Select] <? include "config.php"; $query1="Select *,DATE_FORMAT(date_posted,'%W,%d %b %Y') as thedate FROM article WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) ORDER BY date_posted DESC LIMIT 1 "; $blogarticles = mysql_query($query1) or die(mysql_error()); $num = mysql_num_rows($blogarticles); ?> What I am wanting to find out, is as the blog post itself could be pages long at times, is the anyway that further down the page where I actually call the data up onto the page itself I can limit how much of it is displayed? Ive succesfully added a limit to how many records are shown with the "DES LIMIT 1", is there something I can add to my query, or further down in my displaying table (which I will code just below here) to limit the lines/characters on display until the full article is opened? Display table: Code: [Select] <table width="75%" border="0" cellspacing="1" align="left"> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <? if($num > 0){ while($row_articles = mysql_fetch_assoc($blogarticles)){ ?> <tr class="title"> <td><?=$row_articles['title'];?> </td> </tr> <tr> <td> </td> </tr> <tr class="tbody"> <td><?=$row_articles['comments'];?></td> </tr> <tr> <td> </td> </tr> <tr class="links"> <td>Date posted: <?=$row_articles['date_posted'];?> | <a href="comments.php?aid=<?=$row_articles['artid'];?>&cid=<?=$row_articles['categoryID'];?>">Comments(<? //echo $row_articles['artid']; //$thenum=row_articles['artid']; $getcomments = "SELECT * FROM article WHERE artchild='".$row_articles['artid']."'"; if(!$theResult=mysql_query($getcomments)){ echo mysql_error(); }else{ $num_comments=mysql_num_rows($theResult); echo $num_comments; } ?>) </a></td> </tr> <tr class="links"> <td> </td> </tr> <tr class="links"> <td> </td> </tr> <? } }else{ ?> <tr><td><p>There are no articles available at present</p></td></tr> <? } ?> <tr> </tr> </table> Just to clarify 'comments' is the table field that holds the blog data, it also holds comments on the blog, but the child ID is what differentiates them from one another. Thanks in advance for your help ladies & gents Tom hi, i'm new in php/mysql. i'm stored student marks values in following format in mysql db table. id student_code Tamil English Maths Science Social 1 1 100 75 78 88 95 2 2 85 90 88 80 100 But i want to search and display the specific student marks in following format. id:1 student_code:1 Tamil:100 English:75 Maths:78 Science:88 Social:92 Total:? Avg:? please give correct code for this format. Hi guys I need your help. I would like the data from the column "user_login" being seen as an email link. How can I do that? Thousand Thanks Code: [Select] while($rows=mysql_fetch_array($result)){ ?> <tr> <td><span class="style10"><? echo $rows['user_id']; ?></span></td> <td><span class="style10"><? echo $rows['user_first_name']; ?></span></td> <td><span class="style10"><? echo $rows['user_surname']; ?></span></td> <td><span class="style10"><? echo $rows['user_login']; ?></span></td> <td align="center"><a href="update.php?id=<? echo $rows['user_id']; ?>" class="style10">update</a></td> </tr> <?php } I am seeking to learn more about the noted subject, how to use PHP to allow a user to enter search terms and search a database. I have experimented with this with little results save for errors. Please see code listed below: search.php <? //// filename = search.php <form method="post" action="result.php3"> <select name="metode" size="1"> <option value="row_name1">metode1</option> <option value="row_name2">metode2</option> </select> <input type="text" name="search" size="25"> <input type="submit" value="Begin Searching!!"> </form> ?> results.php //// filename = result.php3 <? $hostname = "mysql7.000webhost.com"; // Usually localhost. $username = "a4542527_root"; // If you have no username, leave this space empty. $password = "*******"; // The same applies here. $usertable = "people"; // This is the table you made. $dbName = "a4542527_test1"; // This is the main database you connect to. MYSQL_CONNECT($hostname, $username, $password) OR DIE("Unable to connect to database"); @mysql_select_db( "$dbName") or die( "Unable to select database"); ?> <? //error message (not found message) $XX = "No Record Found"; $query = mysql_query("SELECT * FROM $usertable WHERE $metode LIKE '%$search%' LIMIT 0, 30 "); while ($row = mysql_fetch_array($query)) { $variable1=$row["row_name1"]; $variable2=$row["row_name2"]; $variable3=$row["row_name3"]; print ("this is for $variable1, and this print the variable2 end so on..."); } //below this is the function for no record!! if (!$variable1) { print ("$XX"); } //end ?> Upon viewing search.php I receive the error message: Parse error: syntax error, unexpected '<' in /home/a4542527/public_html/search.php on line 3 I believe I may be missing something and am a bit lost. Thank-you in in advance for any help or suggestions. ~Matty |