I have this line

<INPUT name=c value="<?php echo href="http://',$data2['c'],' " ',$data2['c'],' ?>"> &nbsp;

and it is giving out this error

Parse error: syntax error, unexpected '=', expecting ',' or ';' in /home/a3024539/public_html/bigtestone1.php on line 21

The output I am looking for is the text from the table to become a link,

Try this:

<INPUT name=c value="<?php echo 'href=http://',$data2['c'],' " ',$data2['c'] ?>">&nbsp;

hi,

I am not sure, what you are trying to make here, but here is an example. Assuming $data is an array..

<?php

    $data2 = array('c'=>'http://google.com');

?>

<input type="button" value="Click Me Please" onClick="alert('Next Time! You don\'t have to click me that hard. Click OK if you agree.'); window.location.href='<?php echo $data2['c']?>'">

I started to wonder the same. You can't have an input text with a clickable link in it. If you want this array to be passed to the input field you can use what veedeoo said which is easier than trying to parse a string like that.

  <?php
           $data2 = array('c'=>'google.com');
           ?>
           <INPUT name="c" value="<?php echo 'http://',$data2['c']?>">&nbsp;
Member Avatar for diafol

From the OP's code - aren't you using ',' instead of '.' ?

//EDIT

Nope that wasn't it :)

What I did was use the input form and changed the name to output, i am thinking of how to make them read only boxes.

Member Avatar for diafol

This is a very odd thing to do :)

But if you want the output suggested by your first code:

<input name="c" value="<?php echo 'href=http://',$data['c'],' &quot; ',$data2['c'] ?>" />

maybe?

i have no clue if its odd or not,
the idea was to take the name , web site and a "pic.link" from the user add it to a base and then display them back as one record at a time with scroll buttons. how would you do it?

the way i am working was
page 1 - hello page with input for name,photo link and auto id, -->gos to page 2
page 2 - process page {adds page 1 data to base} --->gos to page 3
page 3 - output {displays id, name [hyperlinked to website] and pic in box }

I allready have a script {below} that will do some of the above ,only it displays the results in a table and I cant move them around the page. So I am trying to place the outputs in read only text boxes on the page.

$result = mysql_query("SELECT * FROM leader");

echo "<table border='9'>
<tr>
<th>id</th>
<th>Club</th>
<th>Website</th>
<th>Club Badge Url</th>
</tr>";

while($row = mysql_fetch_array($result))

  {
  echo "<tr>";
  echo "<td>" . $row['id'] . "</td>";
  echo "<td>" . $row['club'] . "</td>";


      echo '<td><a class="mylink" href="http://',$row['website'],'">',$row['website'],'</a></td>';

    echo '<td><a class="mylink" href="http://',$row['website'],'"><img width="75" src="',$row['url'],'"/></a></td>';

 echo "</tr>";
  }
echo "</table>";

mysql_close($con);
?> 
<html>
<body>

ok , so I have got the sort of output i want only it comes out in the headder and I cant move it about the page and when it comes to the update page it wont be in a input box to be updatted,

so when i move the same line down into the body into a form , i get the error,

Parse error: syntax error, unexpected '?' in /home/a3024539/public_html/display.php on line 29




<?php

  include('connect.php');



  $data = "SELECT * FROM table1 WHERE id = '1'";

  $query = mysql_query($data);

  $data2 = mysql_fetch_array($query);


         echo '<td><a class="mylink" href="http://',$data2['name'],'">',$data2['name'],'</a></td>';

    echo '<td><a class="mylink" href="http://',$data2['site'],'"><img width="75" src="',$data2['site'],'"/></a></td>';



?><HTML><HEAD><TITLE></TITLE><META content="text/html; charset=utf-8" http-equiv=Content-Type><META name=GENERATOR content="MSHTML 9.00.8112.16457"><STYLE type=text/css>BODY {
    FONT-FAMILY: verdana, arial, sans-serif
}</STYLE></HEAD><BODY><P>
</P><P><FORM method=post action=process.php>


</P><P><INPUT style="WIDTH: 831px; HEIGHT: 386px" value="<?php echo '<td><a class=" href="http://',$data2['name'],'" mylink?>npcomments--&gt;',$data2['name'],'</A></TD>';

    echo '<TD><A class=mylink href="http://',$data2['site'],'"><IMG src="',$data2['site'],'" width=75></A></TD>';
     ?&gt;npcomments--&gt; " size=107&gt;</FORM>
</P></BODY></HTML>
Member Avatar for diafol

ok , so I have got the sort of output i want only it comes out in the headder and I cant move it about the page and when it comes to the update page it wont be in a input box to be updatted, so when i move the same line down into the body into a form , i get the error,

Why are you echoing the output before the html tag?
Place the output in a variable and echo it later on, where you need it.

the line of code work when it is between <head></head> so I just copyed and pasted it down to where I would like it.

is $data2['site'] not allready the variable ? {if not what is it please}

Member Avatar for diafol

You'll want to separate the php from the html as much as possible. PHP shouldn't echo anything out before the doctype declaration (DTD) - which BTW you do not have. If you're using html5, use

<!DOCTYPE HTML>

What type of generator are you using to create this html? Frontpage?

Although, it may be initially easier, these generators create the most god-awful markup you can imagine and I suggest that you do your markup by hand.

So how to proceed?
It may be a personal thing, but I like to run all my functions, includes and various processing before the DTD and save all the various outputs I need in variables, so then it's just a case of echoing out the data where you need it. Of course, there will be times where you need to repeat certain outputs or conditionally display data - so sometimes you include loops (while, do etc) and conditionals (if/else or even switch) in the markup, but if you find yourself having to do a lot of this, then perhaps you should be looking at a template engine, like Smarty or Twig or RainTPL or a hundred other ones.

Anyway this:

echo '<TD><A class=mylink href="http://',$data2['site'],'"><IMG src="',$data2['site'],'" width=75></A></TD>';
 ?&gt;npcomments--&gt; " size=107&gt;</FORM>

Is wrong as you don't have a close php tag (?>) after the </TD>';. I'm assuming that there should be one there?

What's the purpose of this:

?&gt;npcomments--&gt; " size=107&gt;

??

Also you seem to have poor tag ordering, why is the form closed after a td?

Usually you have a table within a form (basic example)

<form>
    <table>
        <tr>
            <td></td>
            <td></td>
            <td></td>
        </tr>    
    </table>
</form>

i am using Trillian to get some of the code and other bits from the net,

?>npcomments--> " size=107>

that as far as i can gather is a bug with Trillian it was

`?>` to close the php tag,{i should of worked that out myself:( }

The idea is to use the same from / box for the text input as the read only output form and a copy of that form as the update form. the table tags should not of been used inside the text box.

Member Avatar for diafol

OK some advice,

Ensure you HTML is sorted before you tackle the php. I don't know what Trillian is, but you put your name to the markup.

The idea is to use the same from / box for the text input as the read only output form and a copy of that form as the update form. the table tags should not of been used inside the text box.

I'm sorry that doesn't make any sense to me. I'm totally lost as to what you're trying to achieve. I've re-read your posts and from what I can gather:

POST

# 1.  You had trouble with parsing a string inside a textbox
# 3,4 You couldn't move the output to the correct place in the page

So are these issues fixed?
What do you need now?

i only have a problem making the text inside a textbox hyperlink , thats all.

it upsets me to think i have upset or confussed you , i do understand your frustration though as i am confussed myself,

Member Avatar for diafol

It's OK. You can't make text inside a textbox a hyperlink - you can only place plain text into it, hence the name 'textbox'.

How do you make a pic and name inside a form hyperlink and also be able to update and change like ,
I was working along the lines of

input form --- input text or pic url into a text box.;[name,pic] **allready works

process page ----takes input data and adds to base.;[id{auto},name,pic] **allready works

display page ------ make form -put box where you want output to be, add data from base into box .{include update button in form to goto-update-processpage};DISPLAY =[id#,name{clickaball to go to www.example.com},pic{clickaball to go to www.example.com}]

is there a way to make the hole textbox including the text inside a hyperlink ?

Member Avatar for diafol

Your display page will not be using a textbox to hold the data (image/text etc). You can use a <div> instead. Why would your data in the display page be in a form? Unless you want to edit the data. Do you?

the data players:{id,name, pic} will be used to update thier score. in most cases will be read-only,

the reason i am or was trying to get the text live in a text box is because my edditor will then in visual mode let me float that box {player} and let me place it anywhere ontop or behind anything else,

and if its not in a form then how duz the program read it to add + 1 to the score laters on ?

the idea i am trying to work towards is one of having a little .gif running in google earth and collecting tokens from hidden places.

is there a way to have this happen with out using forms ?

Member Avatar for diafol

You can use hidden fields to store values and show anything you want on the screen (outside the form).

do you mean like store the {id,name,photo} as a text string in the headder or css file and then display them in the body of an out put form, and have a new form for update as there is no need to have a live link that you are going to change anyway ? will both forms still be able to scroll to the next and last record set ?

Member Avatar for diafol

I'm sorry to say that I'm still pretty confused as to what you're trying to do. You can use ONE form for add and edit (update) a record. Although, sometimes it's easier to use two. The secret for one form scenario is using a 'mode' variable. The mode variable can be set to 'add' or 'edit' - this then sets whether default or record values or additional fields are placed into the form.

However, as I mentioned, it may be easier to have two different forms for add and edit.

Would it be possible for you to make a quick mockup (image) of your add and edit forms and upload it here? If we have a visual, it may be clearer.

c2a3eb56a34ca05a0b1e4760b1706194

I now know part of where i was going wrong , i was thinking i could use the same form as a template for in and out and just move the text box around, however i was trying to put it all into the same page

the code now looks like this and still getting errors.

 <?php
include('connect.php');
$data = "SELECT * FROM table1 WHERE id = '1'";
$query = mysql_query($data);
$data2 = mysql_fetch_array($query);

?><HTML><HEAD><TITLE></TITLE><META content="text/html; charset=utf-8" http-equiv=Content-Type><META name=GENERATOR content="MSHTML 9.00.8112.16457"><STYLE type=text/css>BODY {
    FONT-FAMILY: verdana, arial, sans-serif
}</STYLE></HEAD><BODY>
<?php
echo "<a class="mylink" href="http://',$data2['name'],'">',$data2['name'],'</a>'";
echo " <a class="mylink" href="http://',$data2['site'],'"><img width="75" src="',$data2['site'],'"/></a>'" ;
?>
</P></BODY></HTML>
Member Avatar for diafol

OK, that's better. I'll get back to you with a couple of ideas. Though prob not tonight. ANybody else in the meantime?

Member Avatar for diafol

Seeing nobody wanted to answer. Here something I knocked up quickly. BE AWARE: this is not production code, just something for you to get an idea of how it COULD be done.

I've placed both forms on the same page, with a display record thingy between them. I've not done the validation of post data - you can do that, if you want to do something like below :)

<?php

$id= '';
$name = '';
$site_url = '';
$image_url = '';
$stored_image_url = '';
$image_type = '';
$image = '';

$current_id = 0;

$recs = 0;  //for testing change this to another int to see 2nd form etc.

//Place connection and db select code here

//Check ADD post data - INSERT into DB if set [1ST FORM]
//Also get checkbox value - if set, set $current_id to the last inserted id, otherwise leave as 0

//Check EDIT post data (on edit_send) - get data and UPDATE if set [2ND FORM]

//Check for navigation sends - and prepare an approapriate SQL query based on which nav button and the current id of the 2nd form

//Do query for the display record and the data to show in the 2nd form


?>


<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Sites Admin</title>
</head>

<body>
<h2>Add a Site</h2>
<form id="add_record" name="add_record" method="post" action="addrecord.php">
    <label for="add_name">Name:</label>
    <input id="add_name" name="add_name" type="text" />
    <label for="add_site_url">Site URL:</label>
    <input id="add_site_url" name="add_site_url" type="text" />
    <fieldset>
        <legend>Image</legend>
        <label for="add_txt_image">Remote URL:</label>
        <input id="add_txt_image" name="add_txt_image" type="text" />
        <label for="add_file_image">Upload:</label>
        <input id="add_file_image" name="add_file_image" type="file" />
    </fieldset>
    <input type="checkbox" name="goto_last" id="goto_last" checked="checked" /> <label for="goto_last">Display This on Accept</label>
    <input type="reset" name="add_reset" id="add_reset" value="Reset" />
    <input type="submit" name="add_send" id="add_send" value="Accept" />
</form>

<?php if($recs){ // this is number of records in storage ?>

<h2>Stored Data</h2>
<div id="current_data">
    <p class="id">ID: <?php echo $current_id;?></p>
    <p class="name">Name: <?php echo $name;?></p>
    <p class="site_url">Site URL: <?php echo $site_url;?></p>
    <p class="image_url">Image URL: <?php echo $stored_image_url;?></p>
    <p class="image_type">Type: <?php echo $image_type;?></p>
    <div class="image">
        <?php echo $image;?>
    </div>
</div>

<h2>Edit Stored Data</h2> 
<form id="edit_record" name="edit_record" method="post" action="">
    <label for="edit_id">ID:</label>
    <input id="edit_id" name="edit_id" type="text" value="<?php echo $current_id;?>" />
    <label for="edit_name">Name:</label>
    <input id="edit_name" name="edit_name" type="text" value="<?php echo $name;?>" />
    <label for="edit_site_url">Site URL:</label>
    <input id="edit_site_url" name="edit_site_url" type="text" value="<?php echo $site_url;?>" />
    <label for="edit_txt_image">Remote URL:</label>
    <input id="edit_txt_image" name="edit_txt_image" type="text" value="<?php echo $image_url;?>" />
    <label for="edit_file_image">Upload New File:</label>
    <input id="edit_file_image" name="edit_file_image" type="file" />
    <input type="reset" name="edit_reset" id="edit_reset" value="Reset" />
    <input type="submit" name="edit_send" id="edit_sent" value="Change" />
    <fieldset>
        <legend>Navigation</legend>
        <button class="first" name="first" id="first" value="<?php echo $current_id;?>">First</button>
        <button class="previous" name="previous" id="previous" value="<?php echo $current_id;?>">Previous</button>
        <button class="next" name="next" id="next" value="<?php echo $current_id;?>">Next</button>
        <button class="last" name="last" id="last" value="<?php echo $current_id;?>">Last</button>
    </fieldset>
</form>
<?php } ?>

</body>
</html>

Thanks , that looks like it has all the bits to the jigsaw i need with sum extra,
Talking about which , The file upload button, is to load the .jpg into my base, would this then make me libale for them pics ? where as if the pics are held on say fb or twitter server and i just display a link to them would that not cut down on my storage and libale risks ? will now look up fieldset and legend tags, and the current_id string is new as well, thanks again.

I have sortted this one out ,
have no need to use an input box to show a hyperlink.
any pointers in cleaning this up, would you still sugest using fieldset and legends ? if so where ?

<?php
include('conect.php');
$page = (isset($_GET['page'])) ? $_GET['page'] : 1;
$startPoint = $page - 1;
$data = "SELECT * FROM table1 ORDER BY id ASC LIMIT $startPoint,1";
$query = mysql_query($data);
$data2 = mysql_fetch_array($query);
$rowCount = 0;
?><HTML><HEAD><TITLE></TITLE><META content="text/html; charset=utf-8" http-equiv=Content-Type><META name=GENERATOR content="MSHTML 9.00.8112.16457"><STYLE type=text/css>BODY {
    FONT-FAMILY: verdana, arial, sans-serif
}</STYLE></HEAD><BODY>
<P></P>
<P>
<FORM method=post action=cafeola1.php>
<P></P>
<P></P>
<P align=center><A class=mylink href="<?php echo $data2[i]?>"><?php echo $data2[a]?></A></P><P>


a: <INPUT style="Z-INDEX: 106; POSITION: absolute; TOP: 222px; LEFT: 682px" value="<?php echo $data2[id]?>"> b:<INPUT style="Z-INDEX: 103; POSITION: absolute; TOP: 132px; LEFT: 681px" value="<?php echo $data2[d]?>">&nbsp; c:<INPUT style="Z-INDEX: 102; POSITION: absolute; TOP: 247px; LEFT: 681px" value="<?php echo $data2[e]?>"><BR>
g: <INPUT style="Z-INDEX: 105; POSITION: absolute; TOP: 162px; LEFT: 681px" value="<?php echo $data2[g]?>"> h:<INPUT style="Z-INDEX: 104; POSITION: absolute; TOP: 191px; LEFT: 681px" value="<?php echo $data2[h]?>">&nbsp;<BR></P>
<P>
<IMG style="Z-INDEX: 101; POSITION: absolute; WIDTH: 426px; HEIGHT: 284px; TOP: 176px; LEFT: 183px" border=0 src="<?php echo $data2['i']; ?>" 

<P><BR>&nbsp;</P>
<A href="cafeola1.php?page=1">First</A>
&nbsp;<A href="cafeola1.php?page=<?php echo $page - 1?>">Prev</A>
&nbsp;<A href="cafeola1.php?page=<?php echo $page + 1?>">Next</A>
 <A href="cafeola1.php?page=<?php echo $rowCount?;">Last</A></FORM></BODY></HTML>

still have a problem with LAST,-number records and showing empty records, am still working on the other thread for that .

thanks for all you help on this one.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.