[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 02-16-2007, 01:58 PM   #1 (permalink)
NamePros Member
 
Join Date: Jan 2007
Posts: 68
0.00 NP$ (Donate)

baris22 is an unknown quantity at this point


Mysql_query help

Hello,

I have got a field in mysql. There is <br> after each entry.
The first entry is a link for an image all the time.

So in the row it looks like this

http://www.google.com/a.gif<br>http://www.yahoo.com<br>http://www.aa.com<br>

Ofcourse the links changes for every row. But the first entry is an image file with bmp, gif and jpg extantion at all the time.

Is it possible to disregard the first data in this row when i display the results.
I mean i do not want to show the first data which is the link of the image.

Instead of showing

http://www.google.com/a.gif
http://www.yahoo.com
http://www.aa.com

in the results, I want to show

http://www.yahoo.com
http://www.aa.com

Thank you all.
baris22 is offline  
Old 02-16-2007, 02:01 PM   #2 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
 
Join Date: Feb 2006
Posts: 2,801
56.00 NP$ (Donate)

Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future

Autism Autism Autism Autism Autism Autism Autism
You couldn't stip out the first part through MySQL, but it's simple with PHP.

Query for whichever rows you want and then
PHP Code:
// $var is the row/column data
$var = explode('<br>', $var);
$var = array_shift($var);
$var = implode('<br>', $var);
Dan is offline  
Old 02-16-2007, 02:02 PM   #3 (permalink)
Barru.
 
Barrucadu's Avatar
 
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,731
78.50 NP$ (Donate)

Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold


This is how I would do it, except there is probably a better way.
PHP Code:
<?php
$row_data
= 'blah<br>blah<br>etc<br>';
$i=0;
$row_data2 = explode('<br>', $row_data);

while(
$i < count($row_data2)){
     if(
$i != 0){
          echo
$row_data2[$i] . '<br>';
     }
     
$i++;
}
?>
<edit>
Dan beat me to it - and taught me a new function, yay! lol
Barrucadu is offline  
Old 02-16-2007, 02:16 PM   #4 (permalink)
NamePros Member
 
Join Date: Jan 2007
Posts: 68
0.00 NP$ (Donate)

baris22 is an unknown quantity at this point


How can i use that code for

$row['links']

Thanks



PHP Code:

<?php
ob_start
();
session_start();

$hostname="x";
$username="x";
$password=" x";
$dbname="x";

$con = mysql_pconnect ($hostname,$username,$password) or print "No database connection exists or invalid query<br>".mysql_error();
mysql_select_db ($dbname, $con) or print "Can't select databse <br>".mysql_error();


$result = mysql_query("SELECT * FROM articles");


  
$find[] = '1';
  
$find[] = '2';
  
$find[] = '3';
  
$find[] = '4';
  
$find[] = '5';
  
$replace[] = 'audio';
  
$replace[] = 'video';
  
$replace[] = 'document';
  
$replace[] = 'program';
  
$replace[] = 'others';


echo
"<table width='100%' border='1' cellspacing='0' cellpadding='16' bordercolor='#000000'>
<tr  >
<th bgcolor='#FFCC00'>Num.</th>
<th bgcolor='#FFCC00'>Type</th>
<th bgcolor='#FFCC00'>Title</th>
<th bgcolor='#FFCC00'>Description</th>
<th bgcolor='#FFCC00'>Links</th>
</tr>"
;while($row = mysql_fetch_array($result))
  {
  echo
"<tr>";
  echo
"<td>" . $row['id'] . "</td>";
  echo
"<td>" . str_replace($find, $replace, $row['type']) .  "</td>";
  echo
"<td>" . $row['title'] . "</td>";
  echo
"<td>" . $row['description'] . "</td>";
  echo
"<td nowrap='nowrap'>"  . $row['links'] .  "</td>";
  echo
"</tr>";
  }
  
echo
"</table>";mysql_close($con);
?>
baris22 is offline  
Old 02-16-2007, 05:00 PM   #5 (permalink)
NamePros Member
 
Join Date: Jan 2007
Posts: 68
0.00 NP$ (Donate)

baris22 is an unknown quantity at this point


Quote:
Originally Posted by Mikor
This is how I would do it, except there is probably a better way.
PHP Code:
<?php
$row_data
= 'blah<br>blah<br>etc<br>';
$i=0;
$row_data2 = explode('<br>', $row_data);

while(
$i < count($row_data2)){
     if(
$i != 0){
          echo
$row_data2[$i] . '<br>';
     }
     
$i++;
}
?>
<edit>
Dan beat me to it - and taught me a new function, yay! lol

Thanks

It worked.
baris22 is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 06:14 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85