PDA

View Full Version : how do i do this?[php table change]


filth_?_boy
02-11-2003, 06:59 PM
first, sorry is this is in the wrong forum...

i want to display the progress of a fundraise from donations for a forum.

i've been searching but i don't know what i should be searching for.

so far i've found this

http://www.evolt.org/help_support_evolt/index.html

thats exactly the effect i'm looking for(top left). if someone could explain how its done?

ideally I want to have a form in the admin protected section of vbulletin where we can enter our total needed and achieved thus far. then it displays like evolt.org on the /index.php.

some idea of how its done or what kind of script i can use will help.

cheers

Bane
02-11-2003, 07:59 PM
you could just do something like finding the percentage then using a second table inside with a different colored background and do

<table><tr>
<td width=".$percent." bgcolor="green"> </td>
<td bgcolor="red"></td>
</tr><table>

smoething to that effect.

Bane
02-11-2003, 08:04 PM
$value1="";
$value2="";
$percent = ($value1 / $value2) * 100;
$percent = round($percent)."%";

echo ("<table><tr>");
echo (" <td width=\"".$percent."\" bgcolor=\"green\"> </td>");
if ($percent!="100") { echo("<td bgcolor=\"red\"></td>"); }
echo ("</tr><table>");

would something like that work for you?

filth_?_boy
02-11-2003, 09:46 PM
that looks good thanks.

how can i store the values?

Bane
02-11-2003, 10:17 PM
thats a little more difficult if you want it intergrated with vb, if you dont mind waiting till Im done with my current project I can make a hack out of this, till then you could just use

$value1="189"; // Amount Recieved
$value2="1000"; // Amount We Need

assuming you have earned $189 of the $1000 you need.

filth_?_boy
02-11-2003, 10:24 PM
no i don't need it integrated. I can put that php you made me into the header i would like a

value.cfg file or something the admin could edit and upload to the webroot.

i don't know how to make the values come from another file.

thanks for your help already has made it seem easier though

Bane
02-11-2003, 10:53 PM
include("../value.php");

then put the values in value.php

filth_?_boy
02-11-2003, 10:57 PM
thanks i'll tinker with this tomorrow after some sleep.

cheers

filth_?_boy
02-12-2003, 11:08 PM
hmm i'm not good at this. i can't even make the script start to work. i should say i know nothing about php i'm just fiddling trying to make it work.

i've got my value.php file in the same dir. inside this file i only have
$value1="682"; // Amount Recieved
$value2="1400"; // Amount We Need

now i'm trying to use the php you made me print this html, changing the $ from the values in the include file and altering the size of the table to reflect the donations..
<table width="337" height="52" bgcolor="black" align="center">
<tr>
<td height="26" colspan="2">
<img src="images/donation.gif" width="337" height="26">
</td>
</tr>
<tr height="26">
<td width="65%" bgcolor="#FF0000">
<p align="right">$648 received </p>
</td>
<td>
<p align="right"><font color="red">$880 needed</font></p>
</td>
</tr>
</table>when i put your code into a file eg.<?php
include("value.php");
$percent = ($value1 / $value2) * 100;
$percent = round($percent)."%";
echo ("<table><tr>");
echo (" <td width=\"".$percent."\" bgcolor=\"green\"> </td>");
if ($percent!="100") { echo("<td bgcolor=\"red\"></td>"); }
echo ("</tr><table>");
?>i get$value1="682"; // Amount Recieved $value2="1400"; // Amount We Need
Warning: Division by zero in e:\foxserv\www\2try.php on line 3
i hope its a silly mistake i'm making, i just put the <?php around the whole thing..

thanks for any pointers you can give me...

Bane
02-13-2003, 05:53 AM
First File table.php:
<?php
include("value.php");
$percent = ($value1 / $value2) * 100;
$percent = round($percent)."%";

echo ("<table width=\"150\" border=\"0\"><tr>");
echo (" <td width=\"".$percent."\" bgcolor=\"green\" height=\"10\">".$value1." </td>");
if ($percent!="100") { echo("<td bgcolor=\"red\" align=\"right\">".$value2."</td>"); }
echo ("</tr><table>");
echo ("<br /><br />".$value1."/".$value2);
?>


Second File value.php:
<?php

$value1="682";
$value2="1400";

?>

Bane
02-13-2003, 05:54 AM
this is also assuming they are in the SAME directory. if you have a /forums/ directory and the value.php is in root (/) you need to change the include (like include("../value.php"); )

filth_?_boy
02-13-2003, 06:31 PM
it was the <?php in the value file i hadn't done.

thanks for your help!

Bane
02-14-2003, 07:17 PM
No problem :) Glad its working for you :)