Page 1 of 1
Displaying Certain Row On Page
Posted: Tue Feb 21, 2006 9:46 pm
by nickman013
Hello,
I have a form that inserts data into a database in blob format. The data is put into a HTML code before it is inserted though.
I would like to have a page that displays all of the submitted data, I can do that. But I would like to make a button that displays the selected data on a different page.
Basically I have a page that users contribute to, like videos for example. I would like them to upload videos, and I would like to have all the videos displayed on a page with buttons that I can select a certain one that will be viewed on another page.
I dont know If this clears up what I need help with, if not someone tell me what other info they need.
I do not want people to code it for me, I just want someone to give me a way to create somthing like this, like what would I need to do.
Thanks!
Re: Displaying Certain Row On Page
Posted: Tue Feb 21, 2006 10:01 pm
by josh
nickman013 wrote:like what would I need to do.
Write code?
your answers will be a lot more helpful if you ask specific questions.
Posted: Thu Feb 23, 2006 9:19 pm
by nickman013
Ok, Ive got my form working and inserting the data into the DB.
I have 3 fields in the DB
Number (int,Auto increment) | Code (text) | Live (int)
I would like all the rows that have 1 for live, to be viewed on a page. The ones with 0 for live, dont show up. Anybody got any idea on how I can go about on doing this.
Thank You
Posted: Sat Feb 25, 2006 9:25 pm
by nickman013
Ok, I have got that part working. Now I am on the next part, displaying all of the rows in the database on a page.
Code: Select all
<?php
error_reporting('e_all');
$page = "view submitted.";
$username2= "muot_report";
$password2= "passs";
$database2= "muot_report";
$connection2 = mysql_connect('localhost',$username2,$password2);
mysql_select_db($database2);
?>
<table border=1>
<tr>
<td align=center><font color=red><b>ID #</b></font></td>
<td align=center><font color=red><b>Description</b></font></td>
<td align=center><font color=red><b>Live</b></font></td>
</tr>
<?php
$sql = "SELECT *
FROM `report` DESC";
$query = mysql_query($sql);
while($row = mysql_fetch_array($query)) {
echo '<tr><td>';
echo '<form action=/updateMuot.php method=post>';
echo $row["Code"];
echo '<br>';
echo '<input type=submit value="Make Default Muot">';
echo '<input type=hidden name=who value=$row["Number"]>';
echo '</form>';
echo '</td></tr>';
};
mysql_close($connection2);
?>
</table>
Probably not written right. But It is supposed to display each row, and column in its own cell, with a button, and a field with a hidden value with the number of the row.
It just displays the first row. Nothing else.
Anybody see anything wrong?
Thank you
Posted: Sun Feb 26, 2006 1:30 am
by josh
have you run your query in PHPmyadmin to make sure there are multiple rows being actually returned?
Posted: Sun Feb 26, 2006 1:36 am
by nickman013
What do you mean by run the query in phpMyadmin. Where do I do that. I got the query, where do I test it out?
Posted: Sun Feb 26, 2006 1:44 am
by nickman013
Ah, I seen at the very top where it says SQL, duh !!!.
Is there any way to update all rows in one SQL.
For example
Row 1 // Live - 0
Row 2 // Live - 1
Row 3// Live - 0
Row 4// Live - 0
Is there a way to update all rows so all the Lives for 1,2, and 3 set to 0 and Row for Live is set to 1.
Posted: Sun Feb 26, 2006 2:23 am
by josh
It takes 2 queries
Code: Select all
UPDATE table set `live` = 0
UPDATE table set `live` = 1 WHERE `id` = 2
Posted: Sun Feb 26, 2006 2:44 am
by nickman013
Thanks.
Can you just tell me how to run two querys. Can I do it on the same page?
Posted: Sun Feb 26, 2006 2:46 am
by josh
Code: Select all
mysql_query('UPDATE table set `live` = 0');
mysql_query('UPDATE table set `live` = 1 WHERE `id` = 2');
Posted: Sun Feb 26, 2006 2:51 am
by nickman013
Ah, seems good enough.
Thank You!!!!
