/    Sign up×
Community /Pin to ProfileBookmark

Display Trimmed SQL Output DB Text

Hi I’m sure this is a simple question but I’m just getting my feet wet in PHP right now and I can’t seem to grasp how to get certain outputted sql variables to trim left by a certain amount of charctrs:

[CODE]$query=”SELECT * from table Order by user_id”;
$rt=mysql_query($query);
echo mysql_error();

while($nt=mysql_fetch_array($rt)){
echo “$nt[query1] $nt[query2]”;
}[/CODE]

Thanks.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@welshSep 05.2009 — Im not 100% what you are asking, are you lookin to just display the outputted query or are you looking to display that query however say you are displaying like the word "firetruck" to just display like "truck" (triming the left side?)? but more info on what you want to accomplish would be helpful.
Copy linkTweet thisAlerts:
@theflyingminstauthorSep 05.2009 — Hi Welsh yeah that's exactly what I want to do, but from the other side..

I actually figured it out though.

Thanks much!

$query1tr = substr($nt[query1],0,10);

$query2tr = substr($nt[query2],0,12);
×

Success!

Help @theflyingminst spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...