NameSilo

Mysql_query help

Spaceship Spaceship
Watch

baris22

Established Member
Impact
1
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.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
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:
// $var is the row/column data
$var = explode('<br>', $var);
$var = array_shift($var);
$var = implode('<br>', $var);
 
0
•••
This is how I would do it, except there is probably a better way.
PHP:
<?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
 
0
•••
How can i use that code for

$row['links']

Thanks



PHP:
<?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);
?>
 
0
•••
Mikor said:
This is how I would do it, except there is probably a better way.
PHP:
<?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.
 
0
•••
Appraise.net

We're social

Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back