Jump to content

Recommended Posts

Hello.

I have a function that need to read from the database and display infos on a page:

here's the code i'll explain down what i was thinking:

 

this is the function:

 

<?php
function text_areas_populated($pag)
{
  $gs = strtoupper(substr($pag, 0,1)); 
  // get the table first letter. all the fields in the database have an letter to define what table they are in
  //sTitlu_roN, sStire_roN for example.

  echo "Title news Romana<br />";
  echo 	'<input class="titlu" type="text" name="titlu_ro" value="'.$row_get_.$pag['sTitlu_ro'.$gs].'" /><br />';
  /*
  ....
  */
  echo "News Romana<br />";
  echo 	'<textarea name="stire_ro" class="stire">'.$row_get_.$pag['sStire_ro'.$gs].'</textarea><br />';
  /*
  ....
  */
}?>

 

and this is the calling of the function:

 

<?php
$sql_get_news = "SELECT * FROM t_news WHERE nIdN = '".$_GET['id']."'";
$res_get_news = mysql_query($sql_get_news) or die (mysql_error(__LINE__));
$row_get_news = mysql_fetch_array($res_get_news);

echo text_areas_populated ($_GET['pag']); // where page in this case is news

 

My problem is that nothing is displayed in the input fields.

Can anyone help me with this problem?

Thank you!

 

[edited by kenrbnsn to put in the


tags]

Link to comment
https://forums.phpfreaks.com/topic/72878-_get-problem-in-a-function/
Share on other sites

this is the page:

 

<script type="text/javascript">
function do_change()
{
	if(document.getElementById('id_poza').value == 0)
	{
		document.getElementById('poza_default').innerHTML='<img src="../imag/select_image.gif" />';
	}
	else
	{
		document.getElementById('poza_default').innerHTML='<img src="../imag/poze_stiri/'+(document.getElementById('id_poza').value)+'" />';
	}
}
</script>
<table width="780px" align="center">
<tr>
	<td class="text_top">

                       <?
			echo $_SESSION['news_err']['title'];
			echo $_SESSION['news_err']['stire'];
			echo $_SESSION['news_err']['match'];
		?>
	</td>
</tr>
<tr>
	<td align="center">
		<h3 style="color:#ffffff; font-family:Arial, sans-serif">
      	REVIEW AND PUBLISH NEWS
		</h1>
	</td>
</tr>
<tr>
	<td class="text_top" align="center">
	<form action="stiri_publica.do.php" method="post">

<?php
	$sql_get_news = "SELECT * FROM t_news WHERE nIdN = '".$_GET['id']."'";
	$res_get_news = mysql_query($sql_get_news) or die (mysql_error());
	$row_get_news = mysql_fetch_array($res_get_news);

	echo text_areas_populated($_GET['pag']);


	$sql_select_poze = "SELECT * FROM t_poze ORDER BY sNume_PozaP ASC";
	$res_select_poze = mysql_query($sql_select_poze) or die (mysql_error());
?>

		Select a picture:<br />
		<select id="id_poza" name="id_poza" onchange="do_change()">
			<option value="0">Select a picture</option>
			<?php
			while ($row_select_poze = mysql_fetch_array($res_select_poze))
			{
				?>
				<option value=<?=$row_select_poze['sNume_PozaP']; ?> ><?=$row_select_poze['sAlt_PozaP']; ?></option>
				<?php
			}
			?>
		</select>
		<div id="poza_default"><img src="../imag/select_image.gif"></div><br />
		<div align="center">
			News you are posting will not be automaticaly be inserted into the website. They will be verified by an website admin
			and after that they will be aproved or not to be published!<br /><br /><br />
		</div>
		<input type="submit" class="submit" value="Post news" /><br />
	</form>
	</td>
</tr>
</table>
<?
unset ($_SESSION['news_err'], $_SESSION['posturi_news'], $_SESSION['posturi']);
?>

 

 

and function remain the same.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.