|
||||
| Register--Login--Top 20 Posters--Search Topics |
Forum Main>>Tutorials>>Specifying how many columns per row when extractng from mysq | ||
Chipmunk![]() Rank:Settler of Bobland Group: Head Administrator Posts: 2867 IP Logged PM ID and RPS ID: 1 PM [Chipmunk] View Member Photo | Last replied to on Fri Feb 05, 2010 05:07:20 Edit Post|Quote This is a simple tutorial that shows you how to make information or images(in this case buttons) display in a specific number columns per row using a specific algorithem and loop. First for this example, create a table in mysql called affiliates with the follwing fields: affiliateID -primary, auto-increment, bigint URL - varchar, length 255 button - varchar length 255 URL will store the URL of the site you want to link to, and button will how the URL of the button of that site. Now you need a simple connector file like the following connect.php to connect to the database.
Replace username, password, and database_name with your mySQL username,password, and database name. Now populate the table with some data. Then the actualy file to extract and put the data into a table is as follows:
Entries per line is how many columns per row(in the case, how many buttons to display) per row to display in the table. Right now it is set to five, changing it to different number will cause the table to have different # of columns per row. basically the way it is done is that the $counter variable tracks how many buttons it has displayed so far. Since $entriesperline is how many to display per row, when $counter is a multiple of $entriesperline plus 1, it should start a new row. This is exhibited by the
line. The condition says if this condition happens then print <tr> which is the code for starting a new table. Likewise if $counter is a multiple of $entriesperline, you have to end a row, so the next if statement:
The condition tells it to print a </tr>, which ends a table. However, if there isn't a multiple of $entriesperline for total number of entries in a table, the row won't close. Thats what
is for. If the counter doesn't end on a table end, that line will end the table so as to finish what the loop left out. ----------------------------- Chipmunk, Supreme Administrator | |||||
| itsjustdell Rank:acorn Group: members Posts: 1 IP Logged PM ID and RPS ID: 12202 [PM itsjustdell] RPS score: 0 RPS challenge | Posted at Thu Apr 05, 2007 19:45:00 Edit post|Quote am tryin to make this display 3 column per row, what am i missing or what am i doing wrong?
<? $en['lp_ind'] = 0; ?><!--[Loop Start QUERY:SELECT *,q_name_<%lang%> AS q_name FROM $questtable WHERE q_type=4 ORDER BY q_order ASC]--><? if ($en['lp_ind'] == 0) $en['lp_ind'] = $en['loops_left']+1; $en['lp_ind']--;?><!--[Loop Start QUERY:SELECT * FROM $membtable LEFT JOIN $picstable ON i_user=m_id LEFT JOIN $onlinetable ON o_id=m_id WHERE i_status=2 AND m_confirmed>0 ORDER BY `m_date` DESC LIMIT 100]--><? $en['ftr']++; ?><!--[If Start $en['ftr'] == 1]--><!--[If End]--><!--[If Start $en['loops_index'] == 1]--><!--[If End]--><table border="0" cellpadding="0" cellspacing="4" bgcolor="#FFFFFF" style="margin:3; border:1px dotted #C0C0C0; " width="205"><tr><td rowspan="3" width="65"><a href='<%dir%>view/<%m_user%>.html'><img src='<%dir%>images/pictures/<%m_id%>-<%i_id%>.jpg' width="55" height="55" style="border: 5px solid #c0c8d3;"></a></td><td align="right" width="45" valign="bottom"><font color="000080">name :</font></td><td valign="bottom" align="left" width="128"><a href='<%dir%>view/<%m_user%>.html'><%m_user%></a></td></tr><tr><td align="right" width="45"><font color="000080">age :</font></td><td align="left" width="128"><? $en['mm_year'] = $en['m_year']; $en['mm_month'] = $en['m_month']; $en['mm_day'] = $en['m_day']; echo age(); ?></td></tr><tr><td colspan="2" valign="middle" style="border-top: 1px dotted #C0C0C0"><p align="center"><a href="<%dir%>index.php?req=compose&to=<%m_user%>">send message</a></td></tr></table><!--[If Start $en['loops_left'] == 0]--><!--[If End]--><!--[Loop End]--><!--[Loop End]--><!--[If Start $en['ftr'] > 0]--><!--[If End]--> | |||||
Chipmunk![]() Rank:Settler of Bobland Group: Head Administrator Posts: 2867 IP Logged PM ID and RPS ID: 1 [PM Chipmunk] View Member Photo | Posted at Thu Apr 05, 2007 20:06:37 Edit post|Quote Please use the [.code] and [./code] tags without the . when posting code, I can't read what you just wrote. ----------------------------- Chipmunk, Supreme Administrator | |||||
| 2Gun Rank:acorn Group: members Posts: 1 IP Logged PM ID and RPS ID: 14260 [PM 2Gun] RPS score: 0 RPS challenge | Posted at Sat Nov 24, 2007 19:14:32 Edit post|Quote Chipmunk ...Ive been reviewing your code for displaying images and limiting the number of images per row but havent had any luck getting this to work. If you wouldnt mind ill paste my base source snippet for a image gallery/product list to show you the core for it.
| |||||
Chipmunk![]() Rank:Settler of Bobland Group: Head Administrator Posts: 2867 IP Logged PM ID and RPS ID: 1 [PM Chipmunk] View Member Photo | Posted at Sun Nov 25, 2007 14:18:24 Edit post|Quote Where's your counter for how many columns per row it currently has? ----------------------------- Chipmunk, Supreme Administrator | |||||
| rbr111 Rank:acorn Group: members Posts: 1 IP Logged PM ID and RPS ID: 19381 [PM rbr111] RPS score: 0 RPS challenge | Posted at Mon Jan 19, 2009 03:31:49 Edit post|Quote Ok Chipmunk, nice code; it's working perfectly fine. Some other codes just leave out the first record for no reason.Now how can you specify the number of rows in that result page. For instance, I would like to have a result page with a 3 columns by 3 rows and have the correct number of pages accordingly. just like the repeat region which is included inside Dreamweaver. Can you help? ----------------------------- RBR111 | |||||
| dannyboy Rank:acorn Group: members Posts: 1 IP Logged PM ID and RPS ID: 24972 [PM dannyboy] RPS score: 0 RPS challenge | Posted at Tue Oct 27, 2009 00:50:49 Edit post|Quote Thanks for sharing this post. This is a very helpful and informative material. term life insurance Good post and keep it up. Websites are always helpful in one way or the other, that’s cool stuff, anyways, a good way to get started to renovate your dreams into the world of reality.airline tickets Great tips for money saving. These are the best idea's for money saving and use that money in other useful ways. Other useful ways like that get some training which will useful for you in future. Like different trainings which should have credit in your qualification and job getting. Thanks for sharing your good idea’s.viagra | |||||
| chilpil Rank:acorn Group: members Posts: 2 IP Logged PM ID and RPS ID: 26907 [PM chilpil] RPS score: 0 RPS challenge | Posted at Fri Feb 05, 2010 05:07:20 Edit post|Quote I need some help blocking all traffic from a particular domain referral, lets say 70-680 questions xxx.com. I know this requires mod rewrite to first detect the referral itself and act accordingly, but don't know where to go from there. Can anyone help?The problem I'm facing is that starting recently, a sex related domain has been showing up big time in our referral logs. The referral URL itself is some strange cgi redirect script I can't make heads or tails from (redirects to a 404 page), and it's obvious they're not sending actual visitors to my site. I suspect they may simply be hot linking or accessing some non html files on our server, jacking up the referral logs in the process. Using mod 70-646 exam rewrite would seem to be the only solution, as something like IP tables blocks the domain itself, but not traffic redirected from and not necessarily originating from the offending domain (referrals).70-640 exam questions | |||||
Page: 1 |