PHP - Linking Words From A Mysql Database
Hi,
Currently on my website I have a section where you can select an article held within a database, I still want this to happen but I wouldn't a different word to be linked to the article. Currently it reads 'Click here to view this entry' underneath the title of the article, I want he title of all the different articles to link to the right article is there anyway to do this? My code currently reads: Code: [Select] <?php $blog_postnumber = 5; if(!isset($_GET['page'])) { $page = 1; } else { $page = (int)$_GET['page']; } $from = (($page * $blog_postnumber) - $blog_postnumber); $sql = "SELECT * FROM cms_article ORDER BY timestamp DESC LIMIT $from, $blog_postnumber"; $result = mysql_query($sql) or print ("Can't select entries from table cms_article.<br />" . $sql . "<br />" . mysql_error()); while($row = mysql_fetch_array($result)) { $date = date("l F d Y", $row['timestamp']); $title = stripslashes($row['title']); $entry = stripslashes($row['entry']); $id = $row['id']; if (strlen($entry) > 0) { $entry = substr($entry, 0, 0); $entry = "$entry<a href=\"journal.php?id=" . $id . "\">Click here to view this entry.</a>"; } ?> Similar Tutorialshi every1 im driveing crazy with this... i have a database with a field with descriptions of products named "DESCRIP" in the main page i have a text field where user write the words to search for i wanrt make an "SELECT * FROM models where descrip like xxx OR descrip like xxx... bla bla bla" i wrote this code but send me an error... waht can be wrong??? $word='"SELECT * FROM models WHERE descrip LIKE ' ."'"; $srched=$_POST['words']; $pieces = explode(" ", $srched); $all=count($pieces)-1; for($i=0;$i<=$all;$i ++) { $word = $pieces[$i] ."'"; if($i!=$all) { $word .= $word . ' OR descrip like ' . "'"; } else { $word .= $word .'"' . ";"; } } $colname=$word; mysql_select_db($database_zero1, $zero1); $query_srch = $colname; $buscar = mysql_query($query_srch, $zero1) or die(mysql_error()); $row_srch = mysql_fetch_assoc($srch); $totalRows_srch = mysql_num_rows($srch); tnx in advcd Hello. Racking my brains here, having trouble with this. Running a sports league, trying to get the output of one variable at a different font color OR insert a simple check mark graphic. Either way I am stuck. I am a bit out of practice here. Here is the code. Where is says echo ( Locked) is where I would like to either have locked in a color, say green or red - or insert check mark symbol. Code: [Select] <?php $last = -1; while($team = mssql_fetch_assoc($res)) { if ($last != $team['l_id']) { $last = $team['l_id']; echo "<br><span class=\"dk_greyTxt\" style=\"font-size: 14px\"><strong>$team[night] night, $team[type] $team[size]s $team[division]</strong></span><br><br>"; } echo "<strong>$team[teamname] - ($team[shirtcolor] shirts)</strong><br> RegDate: $team[reg_start]<br>RegDone: $team[reg_done]"; $cpt = mssql_query("SELECT firstname, lastname, shirtsize, feepaid, feememo FROM captain WHERE c_id = $team[captain]",$conn); $c = mssql_fetch_assoc($cpt); if($team["locked"] == 1) { echo " (Locked)"; } else { echo " "; } echo "<br>"; Hi I have a column in my database showing Banned words. What im trying to do is to recall the list of bad words from my database and if some of them is going to be displayed they should replace it with :-x well I made the `$bwords` to recall the info from the database. Hi, I am currently using this code as part of my search module: Code: [Select] $sql_res = mysql_query("SELECT * from test_user_data WHERE streng like '%$q%' or beskrivelse like '%$q%' or sku like '%$q%' ORDER BY streng LIMIT 5"); Simple code that works if my client searches for a string (or part of) that is contained in test_user_data table. If he searches "Dell Inspiron 6000", he will get a hit. However, if he searches for "Inspiron Dell 6000", he will not. Is it a simple way to make the client/enduser search for multiple words contained in a single cell? Thank you! This forum is awesome! I have two tables. Let's call the first one items and the second one item categories. Now the items table would look something like this: id(auto_increment id) name description categoryid The item categories table would look something like this: categoryid name description An entry in the items table would look something like this: categoryid = 1,2 name = Thing description = something id = 1 Say I want to retrieve records that contain "1" in the categoryid column. How would I do that? Hi everyone. I would like to do this: In page1.php, I need to make a few checkboxes, which when the user clicks "next" button, transfers the data (which checkboxes were clicked) to a database table. Then, when the user clicks a button "next", he is moved to another page, page2.php, from which he is automatically transferred to page3.php. At page3.php those values are gathered from the database, and the user has to click "next" button again, then those values are written into another table, in the same or another database. How can I do this? I've not much knowledge with neither SQL, neither PHP. I hope you will help me make this work, I'm making a little system for my HTML website. Thanks, if you do! Here's the scenario: I have an output (list of fields from a database in a table format). It is a list of items in my game, but I want to make the name be hyperlinked to the information from the database (name, attributes, price, etc.). How would I create a hyperlink so that when I do click on the item's name, it will open up the item's information to make it editable? (I have a form that creates the item already, but I want to make it have that information pre-populated for that item so if it needs edited, it could be at that point.) Thanks! Hopefully I explained that ok... Right i want to have friends displayed on peoples profiles but i can only ave there name and not the avater displayed here is the code ive got which doesnt work <? $picture = mysql_query("SELECT * FROM users WHERE username = '$dip->person'"); $pc = mysql_fetch_object($picture); $query_friends=mysql_query("SELECT * FROM friends WHERE username='$viewuser' AND type='Friend'"); $rows=mysql_num_rows($query_friends); if ($rows == "0"){ echo "<center>No friends</center>"; } $friend = 0; while($dip=mysql_fetch_object($query_friends)){ echo " <img src='$pc->image' width='50' height='50' border='1'><br><a href='profile.php?viewuser=$dip->person'>$dip->person</a>,"; $friend++; echo ($friend % 3 == 0)? "<br>" : ""; } ?> The friends are from the friends database and the avater is from the users database how can i link them so the name and the avater show ive tried this but only the names are displayed and the avaters dont show hi all, I am trying to link 2 mysql tables and display some information from each of them. I have a list of all the possible items for sale in table1 and I am trying to count the number of rows in the other table2 where the items exist. E.g. 'table1' manufacturer model man1 item1 man1 item2 man1 item3 'table2' id model 1 item3 2 item3 3 item2 And the result would show: item1(0) item2(1) item3(2) It would list all the items from table1 and show next to it how many rows are related to that item from table2. I have inserted a quote where I have tried many times to enter something similar to that show in the note below - but I can not get it to work - it just shows the total number of models in table1 for a given manufacturer. The php I have made so far is: <?php case 'manufacturer': $query = " SELECT * FROM table1"; $query .= " WHERE manufacturer = '".$data."' "; $query .= " ORDER BY model "; $result = mysqli_query($cxn,$query); $returnData[''] = "Select a Model..."; while($row = mysqli_fetch_assoc($result)){ // I THINK I NEED TO INSERT SOMETHING LIKE $query2 = "SELECT * FROM table2 WHERE model = table1.model"; $k=$row['model']; $k2=$row2['model']; $counter[$k]+=1; $returnData[$k]=$k; } foreach($counter as $k => $row) { $returnData[$k] .= " ($row)"; } break; ?> Hi everyone, I hope I explain my problem well enough. I have created a cms with the help of a tutorial for my website, it allows me to click on the page from a menu and shows me the results. The menu list is taken from my mysql database, so for example i have homepage and recent news in my mysql table and these are what are shown in the menu. What I want is for the menu to to be images that can be clicked to take you to the correct page. I have attached a print screen to show you what it looks like at the minute and what I want the menu to look like. I have no idea if this is even possible can someone please help me out? Hopefully I will hear a reply, I will send my code if needed when I know whether it is possible or not. Thanks in hope Okay so I have 2 tables in my database. One called user and one called messages. A user logs in to the message board and leaves a message (eg nice website). They write in the author name and the message then after the message is posted it says "Nice website" Posted by (author) on (date). All is good so far. It works. However if you look at my code you will see I have a session started. This session is storing the username of the logged in user. From the column username in the users table. (This table has has an id for each user). Ive played around with the code trying to make it so the user doesnt have to fill in the author box. I want rid of that box So the logged in user just leaves a message then it says "posted by (username) on (date). Im missing something from my code. Can anyone tell me what? Please? <?php session_start(); mysql_connect("*************", "*****************", "***************"); mysql_select_db("***********************"); $time = time(); //this checks to see if the $_SESSION variable has been not set //or if the $_SESSION variable has been not set to true //and if one or the other is not set then the user gets //sent to the login page if (!isset($_SESSION['username'])) { header('Location: http://***************.com/login.php'); } $query = "INSERT INTO messages VALUES( NULL, '". mysql_real_escape_string($_POST['message']) ."', '". mysql_real_escape_string($_POST['username']) ."', '$time' )";if( $result = mysql_query($query) ) { if(mysql_affected_rows() > 0 ) { echo "Message Posted.<br><a href='messageboard.php'>Return</a>"; } else { echo 'There was an error posting your message. Please try again later.'; } } else { echo "There was a database error."; // comment out next line for live site. echo "<br>Query string: $query<br>Returned error: " . mysql_error() . '<br>'; } ; Hi, I'm trying to make a mysql output to a link so the name will be a link so when you hit this link you will get the full information of this mysql input. Can someone point me in the correct direction? Here is how i get the output from my mysql database into my table. Code: [Select] <td>"; echo $row['name']; echo "</td> im finding it hard to link PHP, MySQL and dreamweaver together. when php document is alaunched within the localhost all the data in the database is present how ever when the php coding is entered into the html file via dreamweaver no data is present which i think connection to the mysql database cannot be establish why is this can someone help me please, the php document is attached with all the coding [attachment deleted by admin] I have a few tables in a project and i'm linking pages together via PK/FK's. i have a main table with client names, ID, CLIENT NAME, ETC i have a table with communications COMMID, ID, CONTACT NAMES, ETC and another of communication history. COMMHISTORYID, COMMID, DATE, TIME, ETC I'm not sure how to write the query so that i can view/update information from all 3 tables on the same webpage page using php/mysql. I'd appreciate any assistance you may provide. thanks. At the moment I am creating a search function for my website. The approach I have in mind is a pseudo-PHP database. To give an example: A HTML form will submit the results to a PHP file. HTML FORM - Colour: Black PHP RESULT PAGE - if ($_POST['color'] == 'Black') {readfile("./products/black/*.html");} HTML FORM - Price: <$50 PHP RESULT PAGE - if ($_POST['Price'] == '<$50') {readfile("./products/less50/*.html");} The problem here is if there is an item that is black and costs less than $50, then its going to be listed twice. There is probably some code I can write to ommit the listing of duplicate entries, but it is probably going to be messy, so I am wondering if its better to use a centralized MySQL database, rather than a pseudo-PHP database? I've never used MySQL and don't know much about it and this is my first real attempt at using PHP. How would I go about doing the following: I have a csv like this Quote "Division","Section","Group","Product Code","Description","Description + Secondary Description" "Division 1","Section 1","Group 1","BMSLPL25","Test Name","Test Description" "Division 1","Section 1","Group 2","BMSLPL26","Test Name 2","Test Description 2" "Division 2","Section 2","Group 2","BMSLPL27","Test Name 3","Test Description 3" I have a database structured like this Quote Divisions --- id name parent_id Groups --- id name division_id Products --- id code description secondary_description Section is a sub division. What is the best way to get the information from CSV into this database? Should I have another table and store the CSV data as is and then query that to make the other tables. Any help much appreciated. Hi All, Whenever I try to update any piece of PHP code to update a MySQL database, nothing happens. I have tried copying in some of the working codes of a website and tried the same, but no success. I recently installed XAMPP. I am connecting using the correct user id and pass to the database. The scripts are not giving me any error, but just not connecting, that's all. While making such a usage as noted below <FORM name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" > I get the following error Firefox can't find the file at /C:/xampp/htdocs/="<?php.. so on Why does this happen? I am pretty new to this, so please do help. Thanks, Satheesh P R Hi, I wonder if you could help me try to find what i'm looking for, i have a problem with bogus users on my site. I created a register page where the details are sent to the database, this is fine but someone is registering with the username: 1 and password: 1 multiple times. I have about 50 of these now and i would like to know what to actually search for (how to word it) to find out how to stop this? What would be the name of the script? i've looked for fake username script, multiple username/password prevention script, i'm just not getting it, sorry. If any of you have any ideas i'd like to hear from you, many thanks in advance for that. If you need anymore to go on please ask, once again thank you. Hi there, I have been creating a website which shows products of the companys (www.theadventurestartshere.org) and I have been trying to make some filters for the products using URL Parameters and recordsheet filters... Can someone advise me on the easiest way to do this? As I have created a method to do it with, (check website) but it has to be entered manually and I was hoping there is an easier way? Please Note I like to use drop down boxes for the filters but if there is a way to do the checkbox style you see on say Amazon then that would be brilliant... I use Dreamweaver CS5, and the newest versions of PHP and MySql Many Thanks, Paul |