Jump to content
php.lv forumi

kaukaac gljux


keiby

Recommended Posts

ir sekojosh kods :

<?
for($i=1; $i<=$option; $i++){
$subdata=explode("][",$data[$i]);

echo "	<tr>
 <td>Atbildes variants $i : </td>
 <td><input type=\"text\" name=\"answer[$i]\" size=\"40\" maxlength=\"40\" value=\"$subdata[0]\"></td>
 <td><input type=\"text\" name=\"image[$i]\" size=\"25\" maxlength=\"50\" value=\"$subdata[1]\"></td>
 <td><input type=\"text\" name=\"votes[$i]\" size=\"4\" maxlength=\"4\" value=\"$subdata[2]\"></td>
</tr>
";
}
?>

 

kursh nolasa no txt faila datus, kuri, piemeeram, ir saglabaati shaadaa veidaa :

bla bla 1][bla bla][50

bla bla 2][bla bla][60

 

viss, protamz, straadaa, bet man nepatiik viena lieta - kaa vinjsh paartaisa kodu, kas redzams sourcee (shajaa gadiijumaa) :

 

<tr>

 

<td>Atbildes variants 1 : </td>

<td><input type="text" name="answer[1]" size="40" maxlength="40" value="bla bla 1"></td>

<td><input type="text" name="image[1]" size="25" maxlength="50" value="bla bla"></td>

<td><input type="text" name="votes[1]" size="4" maxlength="4" value="50

"></td>

</tr>

<tr>

<td>Atbildes variants 2 : </td>

<td><input type="text" name="answer[2]" size="40" maxlength="40" value="bla bla 2"></td>

 

<td><input type="text" name="image[2]" size="25" maxlength="50" value="bla bla"></td>

<td><input type="text" name="votes[2]" size="4" maxlength="4" value="60

"></td>

</tr>

 

kaa redzams, tad peec treshaas veertiibas (votes) nolasiishanas tiek ielikc enters, tb, viss paareejais tiek paarnesc naakamajaa rindinjaa.

Edited by keiby
Link to comment
Share on other sites

A tu nevari datus glabāt šādi:

bla bla 1][bla bla][50][

bla bla 2][bla bla][60][

 

???

tas dos to, ka tiks ielasīts papildus elements (kuru tu gan nekad neizmantosi, kurā arī būs tas enters).

shitaadu variantu jau biju pirms tam izmeegjinaajis. straadaaja. vnk. pirms tam biju izmantojis shaadu datu saglabaashanas veidu un nebija shitaadas probleemas. taapeec arii prasiiju sheit.

Link to comment
Share on other sites

katrai rindai pēc nolasīšanas no faila vari uztaisīt trim(), tas novāks liekos space sākumā un beigās, kā arī \n simbolu beigās un nebūs tev nekādu problēmu ;)

Link to comment
Share on other sites

1) sadalít ar ko citu, parasti lieto |, jo tas sastopas reti

2) trim, rtrim

3) echo "<td><input type=\"text\" name=\"answer[$i]\" size=\"40\" maxlength=\"40\" value=\"$subdata[0]\"></td>"

vietá izmantot

echo '<td><input type="text" ...</td>'; un nemocíties ar " atsleshoshanu

Link to comment
Share on other sites

×
×
  • Create New...