NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Mysql_query help

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

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 02-16-2007, 02:58 PM THREAD STARTER               #1 (permalink)
NamePros Member
Join Date: Jan 2007
Posts: 98
baris22 is an unknown quantity at this point
 



Mysql_query help


Hello,
????: NamePros.com http://www.namepros.com/programming/295084-mysql_query-help.html

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, 03:01 PM   #2 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
Join Date: Feb 2006
Posts: 2,796
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);
????: NamePros.com http://www.namepros.com/showthread.php?t=295084
$var array_shift($var);
$var implode('<br>'$var); 
Dan is offline  
Old 02-16-2007, 03:02 PM   #3 (permalink)
Senior Member
 
Barrucadu's Avatar
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,689
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>
????: NamePros.com http://www.namepros.com/showthread.php?t=295084
Dan beat me to it - and taught me a new function, yay! lol
Barrucadu is offline  
Old 02-16-2007, 03:16 PM THREAD STARTER               #4 (permalink)
NamePros Member
Join Date: Jan 2007
Posts: 98
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>";
????: NamePros.com http://www.namepros.com/showthread.php?t=295084
????: NamePros.com http://www.namepros.com/showthread.php?t=295084
  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, 06:00 PM THREAD STARTER               #5 (permalink)
NamePros Member
Join Date: Jan 2007
Posts: 98
baris22 is an unknown quantity at this point
 



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);
????: NamePros.com http://www.namepros.com/showthread.php?t=295084

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


Liquid Web Smart Servers  
All times are GMT -7. The time now is 02:55 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger