[PHP-DB] RE: select inside a while loop

2003-11-29 Thread Rolf van de Krol
Hello,

Your code looks well. But is the variable $db the name of your database or
your link-identifier. When it is the name of your database i'm not really
surpised your code wouldn't work. mysql_query requires as second argument a
link identifier.

Rolf van de Krol

-Oorspronkelijk bericht-
Van: Mike Baerwolf [mailto:[EMAIL PROTECTED]
Verzonden: vrijdag 28 november 2003 6:06
Aan: [EMAIL PROTECTED]
Onderwerp: select inside a while loop


Hello,

I have two mysql tables songs and artists. They look like this:

CREATE TABLE `artists` (
   `artist_id` int(10) unsigned NOT NULL auto_increment,
   `artist_name` varchar(100) default NULL,
   `artist_img` varchar(50) default NULL,
   PRIMARY KEY  (`artist_id`),
   UNIQUE KEY `artist_name` (`artist_name`),
   KEY `artist_id` (`artist_id`)
) TYPE=MyISAM;

CREATE TABLE `songs` (
   `song_id` int(11) NOT NULL auto_increment,
   `song_title` tinytext,
   `artist_id` tinytext,
   PRIMARY KEY  (`song_id`)
) TYPE=MyISAM;

Currently I have the artist_id in the songs table setup has a text field
with artist names in them temporarily. First I want to select all the
artist_ids(with the names) and find the artist_id for that name in the
artist table. Then update the artist_id in the song table with the
artist_id in the artist table. Then convert the artist_id in the song
table to int.

So with all that said here is what i have done that doesn't work,

$result = mysql_query(SELECT artist_id FROM songs,$db) or
die(mysql_error());

   if ($row = mysql_fetch_row($result)){
   do {

$artist_name = $row[artist_id];
$result_1 = mysql_query(SELECT artist_id,artist_name FROM
artists WHERE artist_name = '$artist_name',$db);
$row_1 = mysql_fetch_array($result_1);
print $row_1[artist_id]-$row_1[artist_name];

}while ($row = mysql_fetch_array($result));
   }

I haven't even been able to get to the update part. I'm pretty sure the
above fails because of the var $artist_name after the first run through.
Any help would be appreciated.

Thanks,
Mike

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Problema con MySQL

2004-02-03 Thread Rolf van de Krol
Hi Marco,

Please use ENGLISH. This mailinglist is english.

Rolf

-Oorspronkelijk bericht-
Van: Marco A. Ortiz [mailto:[EMAIL PROTECTED]
Verzonden: zaterdag 31 januari 2004 16:45
Aan: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Onderwerp: RE: [PHP-DB] Problema con MySQL


Buenos días a todos:

Espero que alguno de ustedes hable español y me pueda ayudar a descubrir qué
está mal en el siguiente código:

El objetivo de la función  es acceder a una base de Datos (MySQL) y mostrar
los registros que cumplan cierta condición.  Si no existe ningún registro
que cumpla la condición, despliega un mensaje informa al usuario de la
situación, de lo contrario, muestra en una tabla cada uno de los registro
encontrados acompañados de las opciones “Eliminar” y “Editar”.

Por lo menos esto debería hacer. El problema es que no muestra el primero de
los registros que cumplen la condición.  Le he dado mil vueltas y no he
logrado encontrar el error.

function mostrar_articulos_admin($boletin)
{
if (!$boletin == NULL)
   {
   $conn = db_connect();
$query = select id_articulo, titulo_articulo,
autor_articulo from articulo_boletin where id_boletin=$boletin;
$result = mysql_query($query, $conn);
$row = 0;
$hay_arts = mysql_fetch_row ($result);
if ($hay_arts)
{
echo h1Artículos correspondientes al Boletín
$boletin/h1;
echo p\n
table width=\70%\
align=\center\ cellspacing=0\n
tr\n
tdbDetalle
Artículo/b/td\n
td
align=\center\bEliminar/b/td\n
td
align=\center\bEditar/b/td\n
/tr;
while ($fila = mysql_fetch_array($result,
MYSQL_NUM))
   {
$row++;
echo tr
bgcolor=\.color_fila($row).\\n;
echo
tdpb$fila[2]/bbri$fila[3]/i/p/td\n;
echo td
align=\center\a href=\proces.php?action=delartarticulo=$fila[0]\
img
src=\../boletines/ima/eliminar.gif\ border=0/a/td\n;
echo td
align=\center\a href=\proces.php?action=editartarticulo=$fila[0]\
img
src=\../boletines/ima/editar.gif\ border=0/a/td\n;
echo /tr\n;
}
echo /tablebr/p;
   }
else
   {
echo pNo existe ningún Artìculo asociado a este
Boletín.brbr/p;
}
}
else
{
echo pNo ha indicado un número de Boletin Válido,
verifique la información e intente de nuevo./p;
}
}

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] RE: An old dog, with a new trick..

2004-03-18 Thread Rolf van de Krol
I can recommend this book:
PHP4 Bible
 Tim Converse and Joyce Park

http://www.amazon.com/exec/obidos/tg/detail/-/0764549553/qid=1079629430/sr=1
-3/ref=sr_1_3/104-4532765-3387128?v=glances=books
I teached myself PHP with book. (Dutch edition)

Rolf

///
/   Suicidal twin kills sister by mistake!/
///

-Oorspronkelijk bericht-
Van: Felipe Eduardo Ortiz López [mailto:[EMAIL PROTECTED]
Verzonden: donderdag 18 maart 2004 5:05
Aan: lPHP and Databases; [EMAIL PROTECTED]; lPHP For Windows; lPHP
Para Todos
Onderwerp: An old dog, with a new trick..


Bueno, héme aquí, un perro viejo tratando de aprender nuevos trucos.
Comienzo a desarrollar en PHP, con la idea de conectar bases de datos MySQL
y Firebird a las aplicaciones. ¿Me podrían orientar de por dónde comenzar,
libros, sitios, algo así? Les estaré muy agradecido, y disculpen si comienzo
a hacer preguntas tontas...

Well, I'm here, an old dog trying to learn new tricks. I'm starting to
develop in PHP, having the idea to connect MySQL and Firebord databases to
the aplications. Can anyone lend me a hand to have a good starting, bokks,
sites, something else? I'll be very grateful, and very sorry if I'm starting
with the silly questions...

_
Felipe Eduardo Ortiz López,
Consultor.
Tiammat Software.
Yahoo! Messenger: tiammatsoftware
MSN Messenger: [EMAIL PROTECTED]
http://www.prodigyweb.net.mx/tiammat/default.html

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] RE: Drop down menu with PHP

2004-04-05 Thread Rolf van de Krol
Hi Charles,

If you mean columns when you say rows the answer is no. When you mean rows
when your saying rows the answer is yes. That's what you are doing with your
code below.

Rolf

///
/   Suicidal twin kills sister by mistake!/
///

-Oorspronkelijk bericht-
Van: The Image Builder [mailto:[EMAIL PROTECTED]
Verzonden: maandag 5 april 2004 4:01
Aan: [EMAIL PROTECTED]
Onderwerp: Drop down menu with PHP


Hello,

I have code for a drop down menu that works fine.  But, though I only want
the results from one row to fill the form, I want it to show 2 rows in the
drop down menu.  Can I do that? I would appreciate your help.  Here is what
I have now:

? mysql_connect(localhost,user,password);
mysql_select_db(database);
$sql = select distinct category from books ORDER BY category ASC;
$makes_result = mysql_query($sql);
print (select name=\category\\n);
print(option selected value=\\Please select a
Category/option\n);
while($row = mysql_fetch_row($makes_result))
{
print(option value=\$row[0]\$row[0]/option\n);
}
print(/select); ?

Thanks in advance
   Charles

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php