Page 1 of 1

Add new table

Posted: Wed Aug 16, 2006 4:23 pm
by LHOOQ
I have been editing a page on my site, but cannot seem to find the right variables to add another table underneath it.

The table is:

Code: Select all

$pics .= '

<td><img src="'.$VAR[0].'/images/gifts/bargain/1.gif" height="50" width="50"></td>
<td>test</td>
<td>10 points</td>
<td><input type="radio" name="pics" value="10"></td>';

 
}
else {
$pics .= '

<font color="red">
<td><img src="'.$VAR[0].'/images/gifts/bargain/1.gif" height="50" width="50"></td>
<td>test</td>
<td><font color="red">10 points</font></td>';

As you can see, which table the user see's depends on how many 'points' they have.

My problem is that it only shows one box with one item in. I want many items.

Would the code look something like this:

Code: Select all

$pics .= '

<td><img src="'.$VAR[0].'/images/gifts/bargain/1.gif" height="50" width="50"></td>
<td>test</td>
<td>10 points</td>
<td><input type="radio" name="pics" value="10"></td>';

 
}
else {
$pics .= '

<font color="red">
<td><img src="'.$VAR[0].'/images/gifts/bargain/1.gif" height="50" width="50"></td>
<td>test</td>
<td><font color="red">10 points</font></td>';

}
[code here??] {
$pics .= '

<td><img src="'.$VAR[0].'/images/gifts/bargain/2.gif" height="50" width="50"></td>
<td>test</td>
<td>5 points</td>
<td><input type="radio" name="pics" value="5"></td>';

 
}
else {
$pics .= '

<font color="red">
<td><img src="'.$VAR[0].'/images/gifts/bargain/2.gif" height="50" width="50"></td>
<td>test</td>
<td><font color="red">5 points</font></td>';
I am really stuck with this one, can anyone point me in the right direction?

Thanks.

Posted: Wed Aug 16, 2006 4:41 pm
by feyd
It's hard to say for sure, but it's possible to use an if..elseif..else, it's also possible to use a switch.

Posted: Wed Aug 16, 2006 5:15 pm
by LHOOQ
This is some more of the code...

Code: Select all

$dh = opendir("".$VAR[5]."/images/gifts/bargain/");
        $pics = "";
$pics .= '<table border="1" width="100%"><tr>';
$tempo = 0;


	while (($file = readdir($dh)) !== false) {

        	if (eregi("1.gif",$file))
		{



$file_temp = explode("." , $file);
$g = 0;
if ($file_temp[0] <= $activity) { $yes = 1; }
if ($file_temp[0] > $activity) { $yes = 2; }
	if ($tempo == '1') { $tempo = 0; $pics .= "</tr><tr>"; }
if ($yes == 1) {
$g = 1;
$pics .= '

<td><img src="'.$VAR[0].'/images/gifts/bargain/1.gif" height="50" width="50"></td>
<td>test</td>
<td>10 points</td>
<td><input type="radio" name="pics" value="10"></td>';

 
}
else {
$pics .= '

<font color="red">
<td><img src="'.$VAR[0].'/images/gifts/bargain/1.gif" height="50" width="50"></td>
<td>test</td>
<td><font color="red">10 points</font></td>';

 
}
		$tempo++;

}
		}
       
       closedir($dh);

$pics .= "</tr></table>";
So far i can only get 1 table up which has an image in one cell, a description in the another, the cost in points in another and a radio button in another.

Because it uses 'else' to call up a different box depending on the users amount of points i cant add any more tables to appear on the page.

I want to add about 5 more tables with different items to select inside.

do you know how to do this?

Thanks

Posted: Wed Aug 16, 2006 5:28 pm
by feyd
The code posted could only create one table. Many cells, but still only one table.

What's supposed to happen if $yes is 2?

Posted: Wed Aug 16, 2006 6:03 pm
by LHOOQ
What if i used <tr> instead of creating a new table and displayed multiple images within one table. What would the code be for that?

Posted: Wed Aug 16, 2006 6:18 pm
by feyd
LHOOQ wrote:What would the code be for that?
I'm not here to do the work for you, sorry.

I still don't quite understand what you're trying to accomplish or the logic you're using in the code.