PHP/HTML Table Prob

Links for php scripts

Moderators: egami, macek, gesf

Post Reply
snapcrackle
New php-forum User
New php-forum User
Posts: 1
Joined: Thu Mar 23, 2017 1:12 am

Thu Mar 23, 2017 1:39 am

Hi all,

I am fairly new to PHP and am stumped on a problem. I have a html table and I am trying to update information within it via php each time a button is pressed on the website. I have been able to display the number but it only increments once before it finishes. A for loop instead of isset incremented lots of times so i know it isn't the arrays. Seems to be isset. Any clues how I can fix this?

Many thanks,
SC.



CODE:

--- working.php ---
<?php

if(isset($_POST['btn_submit']))
{
$hnumb[0] = $hnumb[0] + 4;
}
else
{
//include ('startarrays.php');
}

include ('carinfo.php');
include ('refresh.php');

?>


--- carfinfo.php ---

<?php
$hname = array('Name', 'Numb',);
$hcar = array("Audi", "Toyota",);
?>


--- refresh.php ---

<style type="text/css">
.tdtext { text-align: center; font-family: verdana; color: black}
</style>

<HTML>

<FONT COLOR="WHITE" SIZE="8" FACE="VERDANA">
<CENTER>PHP TABLE</CENTER>
</FONT>

<BODY bgcolor = "blue">

<br>
<Br>

<center>
<TABLE>
<TH><FONT COLOR="WHITE" SIZE=4>CAR LIST</FONT></TH>
</TABLE>

<TABLE border = 1>
<TR>
<?php
// columns
$i=0;
while($i<2)
{
echo '<th><FONT COLOR="WHITE" SIZE = 3 FACE ="VERDANA">' . $hname[$i] . '</th>';
$i++;
}
?>

</TR>
<?php
// rows
$i=0;
while($i<6)
{
echo '<tr>';
echo '<td>'.'<input type="text" class="tdtext" size= 30 value=' . $hcar[$i] .'></td>';
echo '<td>'.'<input type="text" class="tdtext" size = 7 value=' . $hnumb[$i] .'></td>';
echo '</tr>';
$i++;
}
?>

</TABLE>

<BR>
<BR>

<form action = "working.php" method = "post">

<input type="submit" name="btn_submit" id = "first" value="NEXT" />

</form>


</BODY>
</HTML>


--- startarrays.php ---
<?php

$hnumb = array("0", "0");

?>

User avatar
Strider64
php-forum Active User
php-forum Active User
Posts: 315
Joined: Sat Mar 23, 2013 8:24 am
Location: Livonia, MI
Contact:

Fri Mar 24, 2017 4:27 am

I would first suggest stop capitalizing HTML tags/elements and get a better grasp of HTML/CSS before you tackle php. Tables are meant for tabular data, NOT forms. I wish people who make tutorials on the web would stop doing that! :-x

Use the form to have the user select the options and then you can use a table for the results for that would be tabular data.

Post Reply