/    Sign up×
Community /Pin to ProfileBookmark

Positioning table data

Hi,

I need help to position a list box that I generate in PHP in my page.

I have a form that when submitted contains a “’PHP_SELF’” action to update the current page. I have made a function that creates a populated list box but I don’t know how to position it inside my table or at least under my table.

I don’t know how to call it and from where? Does anybody have any ideas?

claudiaM

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NightShift58Feb 14.2007 — Show us something... At least the function and the recurring part of the table...
Copy linkTweet thisAlerts:
@claudiaMauthorFeb 14.2007 — Thanks for the reply NightShift58, I'm really stuck here.

The function to print the list "pc_grid_horizontal" is below. I can call it from my code as

$selList = selectboxArrayFill(..);//this returns a filled array..no problem here

print $selList; when the form is submitted.

My table is also listed below.

I need to place my list inside a table cell. How can I do that?

My table is inside the form right now.

function pc_grid_horizontal($array, $size)

{

$table_width = 100;

$width = intval($table_width / $size);

$tr = '<tr align="center">';
$td = "<td width="$width%%">%s</td>";

// open table
$grid = "<table width="$table_width%%">$tr";

$i = 0;
foreach ($array as $e) {
$grid .= sprintf($td, $e);
$i++;

if (!($i % $size)) {
$grid .= "</tr>$tr";
}
}

// pad out remaining cells with blanks
while ($i % $size) {
$grid .= sprintf($td, '&nbsp;');
$i++;
}

// add </tr>, if necessary
$end_tr_len = strlen($tr) * -1;
if (substr($grid, $end_tr_len) != $tr) {
$grid .= '</tr>';
} else {
$grid = substr($grid, 0, $end_tr_len);
}

// close table
$grid .= '</table>';

return $grid;

}


<form name="form1" id="form1" method="post" action=<?php echo '"' .$_SERVER['PHP_SELF'].'"'?>>

<table width="100%" border="0" cellspacing="5" cellpadding="5">

<tr>

<td width="18%" align="right"><select name="selectYear" id="select" value="<?php echo $_
POST['selectYear'];?>">

<option value="2006" selected="selected">2006</option>

<option value="2005">2005</option>

<option value="2004">2004</option>

<option value="2003">2003</option>

<option value="2002">2002</option>

<option value="2001">2001</option>

</select>

</td>

<td width="22%"><select name="selectMonth" id="select2" value="<?php echo $_POST['selectMonth'];?>" >

<option value="01" selected="selected">January</option>

<option value="02">February</option>

<option value="03">March</option>

<option value="04">April</option>

<option value="05">May</option>

<option value="06">June</option>

<option value="07">July</option>

<option value="08">August</option>

<option value="09">September</option>

<option value="10">October</option>

<option value="11">November</option>

<option value="12">December</option>

</select>

</td>

<td width="60%"><input type="submit" name="SubmitOld" value="Submit" />

</td>

</tr>

<tr>

<td>&nbsp;</td>

<td>&nbsp;</td>

<td>&nbsp;</td>

</tr>

</table>

</form>
×

Success!

Help @claudiaM 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.9,
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,
)...