Selecting Specific Tag
I am making a script which displays an RSS feed on my website. To do
this I would like to take all the <div class="blabla"><img src="bla.jpg"
alt="bla"> </div> tags and put them in front of my text. So the
following string:
<p>This is text blah blah blah</p>
<div class="blabla"><img src="bla.jpg" alt="bla"> </div>
<p>this is another text</p>
should give as output:
<div class="blabla"><img src="bla.jpg" alt="bla"> </div>
<p>This is text blah blah blah</p>
<p>this is another text</p>
I tried using regular expressions, but I do not really get it done. Here
is the code I use:
while(ereg('/<DIV class="blabla"*>(.*?)</DIV>/i',$content, $matches)){
$img=$img.$matches[0];
$content=ereg_replace('/<DIV
class="imgbar50"*>(.*?)</DIV>/i',"",$content,1);
}
what do i do wrong?
View Complete Forum Thread with Replies
Related Forum Messages:
Selecting Specific Keys
Is there a function I've missed that will shrink my array to only certain key name patterns so PHP Code: $my_array = array('Var1' => "A", 'Var2' => "B", 'Blah' => "C"); //$my_array = somefunction($my_array, "^Var"); foreach ($my_array as $key => $value) echo "$key: $value<br />"; will only echo Var1 and Var2, but not blah.
View Replies !
Selecting A Specific Colum
Ok, I display all the data from the database but what about if after that i want to click certain specific column in the database i have the first page working but i need some help after the user click on the link to see more info about that column Code:
View Replies !
Echo To A Specific Div On A Specific Page
Is it possible to echo something from a php file to a specific div in a different specific html file?If so, can you let me know how to specify where the data should displayed. $myName="john"; echo '$myName'//but i want to echo to a different page on a certain part of that page.
View Replies !
Sending People To Specific Pages That Are Coming From Specific Pages...
I want to show some specific pages to people that comes to my site from specific urls, I know the variable $_SERVER['HTTP_REFERER'] will be used but how? For ex if the visitor comes from a site that is like: I want to send this person a specific.php . I used below code but not worked: <?php if($_SERVER['HTTP_REFERER'] == "www.cominghost.com" || $_SERVER['HTTP_REFERER'] == "cominghost.com" || $_SERVER['HTTP_REFERER'] == "www2.cominghost.com"){ // Specific page html goes here } else { header("Location: index.php"); } ?> This code not worked for some cases like if the visitor comes from http://www.cominghost.com/account/targeturl.php or http://cominghost.com/account/targeturl.php Ok I know the if statement not working but How?
View Replies !
Selecting A Value
i using a registration form. i want to use a tick box to see if they were reffered by somebody. i.e "if you where refered by sombody please tick here []" which will triger a form field to appear so they can tell me who refered them. but if the dont tick the box i need the value to defult to null.
View Replies !
Selecting A Row
I have a database with records, and I show these records in a Table with this code: echo "<table border=Ƈ'> <tr> <th>Name</th> <th>Department</th> <th>Login</th> <th>Employee ID</th> <th>Active</th> </tr>";while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['department'] . "</td>"; echo "<td>" . $row['login'] . "</td>"; echo "<td>" . $row['employee_id'] . "</td>"; echo "<td>" . $row['active'] . "</td>"; echo "</tr>"; } echo "</table>";mysql_close($con); I have three buttons after this code (add, delete and edit). I want to be able to select one row of the table, and send the data in the cells to another php file when I click Edit or Delete, but I have no idea on how to do this. If you have any idea or some help, that would be great. I dont know if I explain this in a good way, if not, I'll try to do it in a better way.
View Replies !
Selecting A DB
I have file that is included in another file that pulls product information to display but whenever I try and select a different db it keeps trying to pull from the main db I am working with. So I am working mainly with db1 and then i use the following code mysql_select_db("msam_cre", $link) or Die("could'nt select database ".mysql_error()); /// echo out the products from the inventory $result = mysql_query("SELECT * FROM products WHERE vendors_id='$_REQUEST[member_id]'") or die(mysql_error()); $count = mysql_num_rows($result); then it tells me table.db1. I am at a loss of what to do here not sure what the problem is. the wierd thing is that if I put in a gibberesh db name in the select db query it tells me that it could not select the database
View Replies !
Selecting Only Some Of Characters In Value
I would like to only select some characters returned from a query. So for example: I have a value that equals "DevShed", I want to set another variable to equal only a portion of that value like "Shed". How do I skip some characters to only show in this case the last 4 characters? $value="DevShed"; <some code here to turn the above variable into> $newValue="Shed";
View Replies !
Selecting From Array
Selecting from the databse, users that would like to be notified for new stores in some city. The column that has city ID's has the following array (for example) 1;2;4;7;9:11;12 Now, when I add a new store in the city with the ID 12, I would like to e-mail my users who have chosen to be notified for new stores in that city. PHP Code:
View Replies !
Selecting From A Drop Down Box
I have a drop down box populated with names of towns from my db (MySQL) all that is working fine. My problem is I do not know how I select a town in the box and have it take me to that web page on my site.
View Replies !
Selecting Som Table Row
Suppose to have a table dinamically created in a form where I show some information of a set of row selected in a db-table: ....... while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td> <inputtype="checkbox"name="checkbox$cnt"value="checkbox"[color=blue] > </td>";[/color] echo "<td>".$row["ID"]."</td>"; echo "<td>".$row["field1"]."</td>"; echo "<td>".$row["email"]."</td>"; echo "</tr>"; } after the table is showed, the user must select some rows checking the related checkbox and then push a button to submit the form; at this point I must start another page where I must do some work only on the rows of the db-table referred by the ID where the checkbox is checked.
View Replies !
Selecting MAX Values
I have a SELECT statement where I use numerous GROUP functions, namely: SUM, MAX and COUNT to query and combine various elements of a table. My question lies around the MAX() function. The field which I am querying for the MAX function is a TINYINT field named HS with numbers ranging anywhere from 0 to 375. However, there is a second TINYINT field named NO which is also tied to it. Basically I would like to add a "*" to the end of the HS field if the NO field is set to 1. If it is set to 0 I would just like it to display the number in the HS field alone. Is it somehow possible to select the NO field of the specific MAX value in the query? If that can be done then I can combine it when writing my php.
View Replies !
Selecting Sets Of IDs
I have an auto incremented ID row in a MySQL table, and the table contains about 180 records. Since I don't want all of my records to show up at once, I wanted to break them down into smaller sections. So say I wanted to just select the first 20 in the table, how would I do that? mysql_query("SELECT * FROM Table WHERE ID=... ? Is it possible to use two conditions in the select query? Like mysql_query("SELECT * FROM Table WHERE ID<=20 WHERE ID>=0"); ? Or does it have something to do with a variable? $first = "<= 20 >= 0"; ?
View Replies !
Selecting Sizes With Php
I need to add products to a database. with sizes i have in stock ie large medium and small. whats the best way todo this. then i want to populate a drop down menu with all the sizes in stock im not sure how to go about this.
View Replies !
Selecting Certain Parts Of An Id
I have message board post IDs like 34.148 or gdis.9834 the bit before the full stop is the forum ID and the bit after is the post ID. What I need to do is select the forum ID and the post ID separately (without the full stop) how would I do this?
View Replies !
Selecting Dates
i have a load of news items stored in a db. the time and date is in a field set as DATETIME how would i select just the news from September 2007?
View Replies !
Selecting 10 Rows Together
I have this script that displays verses out of the bible. The problem is that it is only displaying one verse. I would like for it to display about 10 verses in a row. Random selections though. $result = mysql_query("SELECT * FROM bible ORDER BY RAND() LIMIT 1 "); // WHERE catid <> 'TBP' while($myrow = mysql_fetch_array($result)) { $title = $myrow['book'].' '.$myrow['chapter'].' : '.$myrow['verse'].'<br /> '.$myrow['text']; echo $title; echo "<br />"; echo "<br />"; }
View Replies !
Selecting Part Of A Value
Learning php and mysql, and frankly it's making my head spin... Anyway, how would you get a result and output only part of it? Like get "2004" and only output "04". It's probably a stupid question, but I can't seem to find the correct syntax in any of the manuals. Specifically, I want to output the standard mysql "0000-00-00" date format as "mm/dd/yy". I know there are scripts out there for dates, but I don't want to do anything fancy with it, just switch some numbers around and output part of a result (plus I'm trying to learn this stuff, and this seems like a question that will provide answers for other things as well). An example script would help me alot. From what I know so far, I think the answer would be to select the field, explode the string, then assign and output the variables with "/" in between.
View Replies !
Selecting Records
i need some code that will select all the records in between two dates based on someone entering in these two dates. problem is i have no idea how to code it as i dont fully understand the coding behind it. here is the code <form name="getdates" method="post" action=""> From: <input name="date1" type="date"> To: <input type="date" name="date2"> <input type= "submit" name="datesbetween" value="Get Dates"> </form> <?php $date1 = date(d,m,Y); $date2 = date(d,m,Y); if ($called){ return false else return true $date = mysql_query ("SELECT * FROM calls WHERE calls.called "); }...
View Replies !
Selecting By First Letter
Say I have a list of restaurants and this list is changing all the time so I run a query to get all the restaurants that are in the database. I would like to have something like A-D | E-H....etc. When a user clicks on one of those links it displays restaurants where their names start with that letter. Anyone have any ideas on how to do this?
View Replies !
Selecting Only Rows
I have a small portion of my site dedicated to sorting objects by letter, but when they start with a number I am stuck. how to do this?
View Replies !
Selecting Primary Key
I'm trying to select for the auto-incrememented primary key of a row that has just been inserted in MySQL. I'll need this value immediately after the first insert for subsequent queries. Right now, I can't guarantee for the uniqueness of data in the table, so selecting for the primary key using the rest of the values that had just be inserted isn't an option.
View Replies !
Selecting The Right News
I'm all new into sql and php and need some advice for my newsdatabase. How do I fetch the second newest publicated news with sql and php that has been placed in my database. It should appear in my index.php site. What would the code be to make it happen? I have, somehow, made the latest news display in my index.php. I've been trying to find a good starting example in php-code, but as I'm in what it all means, I'd better not. Anyone to explain and show me ?
View Replies !
Search By Selecting
I am trying to build a recruitment / jobs app for my client. When a user registers they tick various boxes such as good on the telephone can drive fork lift truck...about 20 boxes in total. I want agencies to be able to search by selecting which skills they require. I can do this if it is an exact match using AND so they want FLT driver and good telephone and it brings upo all the ones with JUST them 2 boxes ticked. If there is another, say make coffee well, then it doesnt show them. Is there any way to get it to show this person too.
View Replies !
Selecting Only Certain Items
I am making a review site for a friend, its a movie review website, im using php and mysql (phpmyadmin) and I ran into a problem. I am able to submit, edit, and display reviews, but I have a menu system i want to work but cant figure out how to make it work. The menu system is composed of the letters A-Z and then # for numbers. Each letter is a different button linking to all the reviews starting with that letter. I need to be able to have the user click the letter of choice and then have php read the mysql database and only output tho's movies that start with that first letter or number. I cant find an answer Ive searched and searched and have only found full word matchings.
View Replies !
Selecting Parts Of An ID
I need to select certain parts of my ID's. They are stored like this: //ID// A10-0 A10-1 A124-0 A124-1 A124-2 A28-0 Now I just need to select the parts shown below: //ID// A10 A124 A28 So somehow I need to snip the text off after or before the "-" How can I do this please?
View Replies !
Selecting Data
i have about 200 bits of data in one my tables, now i have it displaying perfect, but on a certain page i need just one row of data from that perticular table out of the 200 so i try this. SELECT * FROM my_table WHERE name='octavio' , hoping it would only show that data for that row.
View Replies !
Selecting Certain Row In MYSQL
I need to select multiple rows(ie, the where won't work in this situation). In MYSQL I have the members information. From there I need to pull datat from column 1, 2, 3, 5, and 8.
View Replies !
Selecting From Database
I have a mysql table called fixtures, which has the rows player_id and wk1, wk2, -38. The wk fields relate to a player_id . I want to be able to call the fixtures from say wk1 without repeating the player ids (i.e the fixtures will only be displayed once and wont list 1-v-2 and 2-v-1) So it will be something like: Fixtures (week 1): player_id - 1 -v- 2 player_id - 3 -v- 4 player_id - 5 -v- 6 It does not matter what is listed first, there are no home or away games. I hope that makes sense! I cant think of another way of describing it.
View Replies !
Selecting By Date
I am trying to access a list of items from a table between to date values. I have the following to set the dates. PHP Code: $fromdate = mktime(0,0,0,$frommonth,$fromday,$fromyear); $todate = mktime(0,0,0,$tomonth,$today,$toyear); then the following query. PHP Code: echo("$fromdate <br> $todate"); $query = "SELECT item_name, mc_gross, completed, COUNT(*) countvalue FROM ipn_tblsaleshistory GROUP BY item_name WHERE completed BETWEEN '$fromdate' AND '$todate' ";...........
View Replies !
Selecting Distinct
I have this SQL statement SELECT DISTINCT fName, lName, sex FROM Users But I also want to return the id field corresponding to each row in the Users table. So something like this SELECT id, DISTINCT fName, lName, sex FROM Users (which obviously doesnt work). Is there a way to write an sql statement to do this?
View Replies !
Selecting Record
I have a table containing details of prizes in a raffle. The raffle is promoted through a banner on every page of the site. Each page impression features details of a different prize, selected by random key. Now, I want to give extra promotion to prizes worth the most. So, for example, I want Prize A, worth $100, to get 10 times more promotion (page displays) than Prize B worth $10. The prize value is available in a column in the table of course. how I can achieve this?
View Replies !
Selecting And Echoing
i have values in a table which represent currency, US$. i need to do no calculations on these values. they could be numbers of chickens, and it would still function the same. if i wish to print this value to screen, should i just use the $ in my html block, or should i use MySQL or PHP to show the dollar sign to represent that it's currency? from your experience, what do you think is best? i want to get into a "good habit" here, so maybe i should use something that would work if i were doing calcs on the numbers, or what not.
View Replies !
Selecting With A Variable
I am wanting to make a register page for a game I'm making, and was wanting to make it so that if an email was already used it would return "Email already in use", but insert the data if it wasnt already used. PHP Code: <? }; if ($action == "submit") { $email = $_POST["email"]; $pass = $_POST["pass"]; $name = $_POST["name"]; $group = $_POST["group"]; include ("config.php"); $checkwebaddy = mysql_query("SELECT email FROM members WHERE email = $email"); ................
View Replies !
Selecting From Mysql
I want to group rows that has the same value in a specific column like: row1: 3 row2: 2 row3: 3 what do i do now to select row 1 and 3? The query has to be dynamic because the numbers can be any from 1 to 1000.
View Replies !
Selecting By Month
i am looking for the simplest way to select each record from MySQL that occurs within a month because i have to use another value in each record to build a graph up to the current month in a year. for example if this is May, i need to process the records for jan - may. i could use strftime to get the current month and year. but it seems that there should be an easier way.
View Replies !
Selecting The Next Language
We are a software company that provides Inventory & Procurement mangement to the hospitality industry. For the past twenty years we have been using Progress Software as both the development language and the underlying database. We are in the process of exploring new languages to write our application in, as Progress is becoming expensive for us. Code:
View Replies !
Selecting Problems
I have a website that has users and artists on it. I am building the community page ( the page that displays everyone in the db) well i figured out the view all artists and all people but i need help figuring out how to just view the customers without the artists on the page. My db is set up like this --|customers|-- --|artists|-- screenname +---customer_id email points password customer_id ---+ and my code for the query is this so far $query = "SELECT * FROM ".$glob['dbprefix']."customer LEFT JOIN ".$glob['dbprefix']."artist ON ".$glob['dbprefix']."StreamRush_customer.customer_id=".$glob['dbprefix']."artist.customer_id WHERE private = 0 ORDER BY noOrders";
View Replies !
Selective Selecting.
I have a 'search' form that lets users search my database. I have a set of checkboxes in that form. []Area1 []Area2 []Area3 I'm having trouble figuring out how to filter my database query based on which boxes are checked.
View Replies !
Selecting A Range
How does one select a certain range of arrays without having to write them all out? I am wondering, how would one go about the following? So we have the following indexed arrays: $array[0] = "A"; $array[1] = "B"; $array[2] = "C"; $array[3] = "D"; i'd like this fantasy if statement to work: if ($array[range 0-3] != A) print "blah blah blah"; elseif ($array[range 1-2] != A) print" do de do "; of course me putting the range inside the brakets is an absolute violation and won't work, how would i go about coding this properly?
View Replies !
SELECTing Using DATE_FORMAT
I have been trying to run this MySQL query using PHP: SELECT id, trans_type, remote_addr, DATE_FORMAT(time, '%M %e, %Y %r') as time FROM transactions WHERE client_id = " . $client_id . " ORDER BY time asc and I am getting this error message: MySQL Error number: 1064: You have an error in your SQL syntax near 'ORDER BY time asc' at line 2 I added the "as time" in hopes it wasn't seeing the 'DATE_FORMAT()'field as the time field.
View Replies !
Selecting Rows
How should I do my SELECT so that it will give me a random row from the current date up to 7 days back? AT this point I am doing it manually but I know it is not the right way to do it because I would have to change the date everyday: Code: .....
View Replies !
Selecting WHERE Problems!
I need to select data from directory where clean1_id = $carpet_cleaner1 OR $window_cleaner1. My first problem is at the moment the code below only gets data for $carpet_cleaner1. My second problem is that I would like to have a WHERE that looks for clean1_id,clean2_id OR clean3_id and any of these equal to $carpet_cleaner1 OR $window_cleaner1. So it will be any of the clean_id's equal to any of the $cleaners. "SELECT * FROM directory WHERE authorised = 'Y' AND clean1_id = '$carpet_cleaner1' OR '$window_cleaner1'";
View Replies !
Mysql Selecting
Im trying to make an order reporting page that gets all the orders from any month and any year. It will look something like this: $sql = "SELECT * FROM orders WHERE ..."
View Replies !
Selecting With Lots Of AND/ORs
I have table which contains two values, start date and end date. It also contains a category field, which can be one of a few values. I want a query that selects everything between $startdate and $enddate but only returns results where the category is equal to $cat1 or $cat2. Thye query I have at the minute isn't working: SELECT * FROM `events` WHERE `start` BETWEEN ?' AND ?' AND `category` = 'General' OR `category` = 'Meetings' It's as though I need to put brackets around it if I could, because it's treating it as: WHERE `start` BETWEEN ?' AND ?' AND `category` = 'General' OR `category` = 'Meetings'.
View Replies !
Selecting Php Into Tables
Selecting php into tables with multiple columns? I know how to select the data into tables with one column, but how do you select into 4 columns and 4 rows.
View Replies !
Selecting All Records
I am currently building a PHP/MySQL site, and am stuck creating a particular querey to do with and events calendar kind of thing. I have a table on my database where one field is a datetime type field with the date and time of the event in. What i am wanting to do is use the WHERE in my querey to select all records where the datetime field is in the month of October 2004 for example but i cant seem to figure out how to get this working.
View Replies !
|