Re: Working with variables and MySQL



On 2008-05-20, Ar <Ar@xxxxxxxxx> wrote:
I have a MySQL database table that keeps track of lots of numbers for
event outcomes.

For simplicilty, and to make it easy for arithmetic work, and to keep the
database small, all the variables are of type integer. However, I have
entered into the tables scores that that are not normally expected to
indicate specific conditions, like (integer) 44 for example meaning
"Event Cancelled" etc.

While I have no problem reading the MySQL table row data out into a
webpage (see code below), I do not know how to do text substitutions
WITHOUT changing the database data, ie. only substitute as it's being
read out of the database. I'm still very sketchy on arrays, and that's
what's causing the problem for me.

So I have something like the following;


while ($row = @mysql_fetch_array($theresults))
{
$Theid = $row['EnteredNumber'];
$1stresult = $row['Finished1'];
$2ndresult = $row['Finished2'];

while ($row = @mysql_fetch_array($theresults)) would normally be:

while ($row = @mysql_fetch_array($theresults,MYSQL_ASSOC))

assigning variable names to the output isn't necessary:

$display_entry .= "$row[EnteredNumber], $row[Finished1]<BR>";

and finally, maybe

if($row['Finished2']=44)
$row['Finished2']="Cancelled";

assuming you don't have to make too many of these changes.

ken
.



Relevant Pages

  • Re: Treating text copied from MS Word
    ...  When he's adding stuff to the database he's ... copying text from MS Word. ...  I've tried various substitutions that I've found ... hanging around the internet, but nothing's working for the "long dash" that ...
    (comp.lang.php)
  • Working with variables and MySQL
    ... I have a MySQL database table that keeps track of lots of numbers for ... event outcomes. ... database small, all the variables are of type integer. ... The variables to display on the webpage are many more than the three ...
    (alt.php)
  • Re: data type mismatch
    ... > database. ... > UniqueID is a numeric field of type integer ...
    (microsoft.public.vb.general.discussion)